Conversation
get_parameter() iterated over the outer Value node when looking for the extended-attrtext terminal that contains the RFC 2231 charset. Since the terminal is nested inside an Attribute or QuotedString, the loop never reached it. Descend into the charset container before retyping the terminal as attrtext, and use stripped_value for Parameter.charset so trailing CFWS is not included.
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.
While writing test cases, I found that the
forloop here iterates over aValuetoken list whose only child is theAttribute(orQuotedString) containing the terminal, for example:As a result, the loop never reaches the
extended-attrtextterminal, so thebreakcondition is never satisfied.Parameter.charsetis therefore taken from the enclosing token and includes any CFWS following the charset. It also means that the loop's intended purpose—retyping theextended-attrtextterminal asattrtext—cannot take effect.I decided to fix this by first descending into the child token that contains the charset, then retyping the actual
extended-attrtextterminal asattrtext. The charset value is taken from the child token'sstripped_value, so any surrounding CFWS is preserved in the parse tree but excluded fromParameter.charset.