Convert string-like values to plain strings in Entry#1337
Merged
paranoidi merged 2 commits intoFlexget:developfrom Aug 15, 2016
Merged
Convert string-like values to plain strings in Entry#1337paranoidi merged 2 commits intoFlexget:developfrom
paranoidi merged 2 commits intoFlexget:developfrom
Conversation
91f6079 to
5d08fa3
Compare
BeautifulSoup, as used in some search plugins, returns strings from HTML document structures in "enriched" form - instances of unicode/str mixed in with another class. Those strings carry references to the whole document tree, which can cause issues when attempting to serialize entry values for saving to the database. To avoid that, coerce any values whose type is a subtype of text_type, but not *exactly* text_type, to text_type, with text_type being unicode in Py2 and str in Py3. That should ensure we throw away any extra baggage that might be attached but keep the exact same content.
5d08fa3 to
fb3dbc9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation for changes:
BeautifulSoup, as used in some search plugins, returns strings from HTML
document structures in "enriched" form - instances of unicode/str mixed
in with another class. Those strings carry references to the whole
document tree, which can cause issues when attempting to serialize entry
values for saving to the database.
Detailed changes:
To avoid that, coerce any values whose type is a subtype of text_type,
but not exactly text_type, to text_type, with text_type being unicode
in Py2 and str in Py3. That should ensure we throw away any extra
baggage that might be attached but keep the exact same content.
Supersedes #1302 and fixes #1301.