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

Handle XML embedded in tilesource JSON #2328

Merged
merged 1 commit into from Apr 4, 2023

Conversation

craigberry
Copy link
Contributor

The existing check for whether the tilesource data is XML or JSON looks for a tag anywhere in the response content, which incorrectly flags the content as XML in the case where it is really JSON with XML embedded in it.

This commit corrects that problem by requiring the tag to occur as the first non-whitespace part of the content. This is basically a poor person's well-formedness check since well-formed XML cannot have non-whitespace content outside of the root node.

N.B. While malformed XML content with non-whitespace characters before the first element has been getting identified as XML, it has not been getting parsed correctly. With current parsing infrastructure, the content has been getting replaced by a parsing error message. With more up-to-date parsing infrastructure, it will throw an error. Either way we're not losing anything by failing to identify malformed XML as XML.

Addresses issue #2325.

The existing check for whether the tilesource data is XML or JSON
looks for a tag anywhere in the response content, which incorrectly
flags the content as XML in the case where it is really JSON with
XML embedded in it.

This commit corrects that problem by requiring the tag to occur as
the first non-whitespace part of the content. This is basically a
poor person's well-formedness check since well-formed XML cannot
have non-whitespace content outside of the root node.

N.B. While malformed XML content with non-whitespace characters
before the first element has been getting identified as XML, it
has not been getting parsed correctly.  With current parsing
infrastructure, the content has been getting replaced by a parsing
error message.  With more up-to-date parsing infrastructure, it
will throw an error.  Either way we're not losing anything by failing
to identify malformed XML as XML.

Addresses issue openseadragon#2325.
Copy link
Member

@iangilman iangilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Thank you for fixing this :)

@iangilman iangilman merged commit cec0aca into openseadragon:master Apr 4, 2023
1 check passed
iangilman added a commit that referenced this pull request Apr 4, 2023
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.

None yet

2 participants