[release/5.0-preview4] Single-File: Fix a json parsing issue#35656
Closed
swaroop-sridhar wants to merge 1 commit intodotnet:release/5.0-preview4from
Closed
[release/5.0-preview4] Single-File: Fix a json parsing issue#35656swaroop-sridhar wants to merge 1 commit intodotnet:release/5.0-preview4from
swaroop-sridhar wants to merge 1 commit intodotnet:release/5.0-preview4from
Conversation
…hitectures (dotnet#35073) RapidJson's `kParseStopWhenDoneFlag` indicates that parsing should stop once the root element is parsed, and should not throw an error for any further content. This flag is useful when the input stream doesn't always have a null-terminator -- ex: an input `bytestream` (rather than a `stringstream`), files embeded within the single file bundle. The limitation of using this flag is that any actual random text after the root element is silently ignored. Currently, RapidJson is invoked with `kParseStopWhenDoneFlag` on Windows, but not on Unix. This caused `kParseErrorDocumentRootNotSingular` failure on Unix when parsing json files from single-file bundles. This change fixes this problem by passing `kParseStopWhenDoneFlag` on all platforms. This also makes the host behavior consistent across platforms.
|
Tagging subscribers to this area: @vitek-karas, @swaroop-sridhar |
vitek-karas
approved these changes
Apr 30, 2020
Contributor
Author
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Customer Scenario
Single File apps fail to run on some Linux systems
Problem
Single-file apps now process json config files directly from bundle (#34274).
When parsing json files from memory-mapped files, RapidJson in-situ parsing complains about bytes mapped beyond the end of the file, assuming that they represent content beyond the root element.
Solution
Ask RapidJaon to stop parsing at the end of the root element, similar to Windows.
Details
RapidJson's
kParseStopWhenDoneFlagindicates that parsing should stop once the root element is parsed, and should not throw an error for any further content.This flag is useful when the input stream doesn't always have a null-terminator --
ex: an input
bytestream(rather than astringstream), files embeded within the single file bundle.The limitation of using this flag is that any actual random text after the root element is silently ignored.
Currently, RapidJson is invoked with
kParseStopWhenDoneFlagon Windows, but not on Unix.This caused
kParseErrorDocumentRootNotSingularfailure on Unix when parsing json files from single-file bundles.This change fixes this problem by passing
kParseStopWhenDoneFlagon all platforms.This also makes the host behavior consistent across platforms.
Master Branch
PR: #35073
Commit: 342ed3c
Risk
Very Low