Repository navigation
Quote operator symbols containing // or /* in the text writer - #1171
Open
radhika1314 wants to merge 1 commit into
Open
radhika1314 wants to merge 1 commit into
radhika1314 wants to merge 1 commit into
Conversation
A symbol made only of operator characters is written unquoted inside an s-expression, but // and /* start a comment when the text is read back, so the symbol and whatever follows it on re-read are lost or reparsed.
This branch has not been deployed
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.
Issue #, if available:
Description of changes:
IonTextUtils.symbolVariantand_Private_IonTextAppender.symbolNeedsQuotingtreat any symbol made only of operator characters as an operator, so the text writer andPrinteremit it unquoted inside an s-expression.//,/*and anything containing them (+/*,*//) are all operator characters, but the text reader starts a comment at/followed by/or*, so the written text no longer reads back as the same data.(// x)is whatIonTextWriterBuilderandIonValue.toString()currently produce for a sexp of the symbols//andx. Reading it back dropsxand everything else on the line./*, the comment runs until the next*/, including one inside a later string. A pretty-printed{tags:(/*), role:user, note:"*/), role:admin, note:1 //"}reads back as{tags:(), role:admin, note:1}, so an application that writes untrusted symbol text can have other fields replaced on re-read.Both helpers now quote the symbol when a
/is directly followed by/or*. A lone/or*/still goes out unquoted. Added cases toTextTest.testSymbolNeedsQuotingand a round-trip test toTextWriterTest. Both fail without the change and pass with it, and./gradlew buildis green. The header rewrites in the touched files come from the spotless ratchet.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.