Recognize XML declarations when detecting response encoding - #335
Open
OskarEichler wants to merge 1 commit into
Open
Recognize XML declarations when detecting response encoding#335OskarEichler wants to merge 1 commit into
OskarEichler wants to merge 1 commit into
Conversation
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.
Summary
Recognize the
<?xmldeclaration prefix when detecting response encoding. The existing expression matches<xmlinstead, missing real declarations and interpreting an ordinary xml element as one.Reproduction
An XML response with
body_encoding = trueand a binary body beginning<?xml version="1.0" encoding="ISO-8859-1"?>is tagged UTF-8 despite the declaration. After the one-character correction, the response uses ISO-8859-1 without changing its bytes. Conversely, an ordinary<xml version="1.0" encoding="ISO-8859-1"/>element no longer changes the encoding.The XML declaration grammar uses the
<?xmlprefix.Verification
bundle exec rake test: 201 tests / 914 assertions / zero failures or errors, baseline and isolated patch.git diff --checkpass; supplemental Lint scan has the same 25 baseline findings.Compatibility and limitations
No API/dependency/Ruby-requirement change. Intentional behavior correction: real declarations are recognized; ordinary xml elements are not treated as declarations. This is not a full XML parser and does not change media-type matching or the rest of the declaration grammar. Other Ruby/OS combinations and optional external OpenSSL checks were not run.