Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional xml.sax features #26

Merged
merged 3 commits into from
Mar 9, 2017
Merged

Conversation

ransford
Copy link
Contributor

@ransford ransford commented Aug 22, 2016

I'm using untangle to parse XML files and it's great. However, I'm operating offline, and by default xml.sax tries to load external entities such as DTDs. Loading external entities is a controllable parser "feature."

This PR adds the ability to pass xml.sax parser features as extra arguments to parse(), so for example

untangle.parse(my_xml, feature_external_ges=False)

becomes

parser.setFeature(xml.sax.handler.feature_external_ges, False)

parse() raises AttributeError if a nonexistent feature is requested.

Ben Ransford and others added 2 commits August 22, 2016 14:46
After initializing an xml.sax.parser, optionally set feature values on it before
parsing content.

For example, to turn off the loading of external DTDs, call

    untangle.parse(thing, feature_external_ges=False)

References including lists of features:
- https://docs.python.org/2/library/xml.sax.handler.html
- https://docs.python.org/3/library/xml.sax.handler.html
@coveralls
Copy link

coveralls commented Aug 22, 2016

Coverage Status

Coverage decreased (-0.7%) to 36.0% when pulling a125e3c on ransford:xml-sax-features into 8e07869 on stchris:master.

@coveralls
Copy link

coveralls commented Aug 23, 2016

Coverage Status

Coverage decreased (-0.7%) to 36.0% when pulling 3b8d847 on ransford:xml-sax-features into 8e07869 on stchris:master.

@ransford
Copy link
Contributor Author

ransford commented Feb 7, 2017

Is this likely to be merged?

@stchris
Copy link
Owner

stchris commented Feb 10, 2017

I'm sorry, I didn't find any time recently to work on untangle. I want to make a new release soon and I'll definitely look at your PR as well.

@stchris
Copy link
Owner

stchris commented Mar 9, 2017

LGTM! I'll add an example to the docs and I hope to release a new version soon. Thanks for the PR! 👍

@stchris stchris closed this Mar 9, 2017
@stchris stchris reopened this Mar 9, 2017
@stchris stchris merged commit f14eb11 into stchris:master Mar 9, 2017
stchris added a commit that referenced this pull request Mar 9, 2017
stchris pushed a commit that referenced this pull request Mar 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants