Repository navigation
Write the usage sharing record as the specification says - #81
Merged
Merged
Conversation
The record marks invalid characters with escaped, marks a long value with truncated, follows the order of the specification's example and uses neither CDATA nor BadSchema.
Mark an Evidence value that had invalid characters replaced with the escaped attribute, where it had a replaced attribute, and write the elements in the order of the specification's example.
…er limit An invalid character is written as backslash, x and four lower-case hexadecimal digits, a value is cut at 10,000 characters without splitting a surrogate pair, and every character XML 1.0 allows is kept.
…ters A character XML 1.0 does not allow is written as backslash, x and its code as four lower-case hexadecimal digits, where it was replaced with U+FFFD. The limit is 10,000 characters, counted as characters so that a pair of surrogates is never split, where it was 512 UTF-16 code units.
…acters are escaped
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.
The problem
pipeline/Gaps-vs-spec.mdlists where the Java usage sharing record differs from the specification. The Processing section of the Usage Sharing Element page says:<PREFIX [escaped=true] [truncated=true] Name="FIELD">VALUE</PREFIX>, withSessionId,Sequence,DateSent,Version,Product,FlowElement,Language,LanguageVersion,ClientIP,ServerIPandPlatformin that order.Java marked an Evidence value that had invalid characters replaced with
replaced="true", wroteVersionand the server details beforeSessionId,SequenceandDateSent, replaced each invalid character with U+FFFD and cut values at 512 UTF-16 code units. The record rules for the escape and the limit are in the specifications draft #122, which says:\xfollowed by the code of the character as four lower-case hexadecimal digits, for example\x001f, and the element for that Evidence entry is markedescaped="true"."truncated="true". The limit counts Unicode code points, and the cut never splits a character, so a surrogate pair is never divided."What changes
In
ShareUsageElement.writeXmlData:escaped="true", where it wasreplaced="true", andtruncated="true"is unchanged.\xand four lower-case hexadecimal digits (\x001f), where U+FFFD replaced it. The characters XML 1.0 allows are kept, which is every character in theCharproduction of section 2.2: tab, line feed, carriage return, U+0020 to U+D7FF, U+E000 to U+FFFD and U+10000 to U+10FFFF. A surrogate on its own, U+FFFE and U+FFFF are written as escapes.ReplacedStringcounts characters withcodePointCountand cuts atoffsetByCodePoints, so a pair of surrogates is never split, andConstants.SHARE_USAGE_MAX_EVIDENCE_LENGTHis 10,000.Not changed:
BadSchemaelement, as the page says.\x001freads the same as an escaped character. The decision above does not escape it.version="1.1"attribute on<Devices>stays. The page asks only for a<Devices>root element and says nothing about attributes on it.Behaviour that changes for the receiver
The attribute name
replacedis gone and the same information is inescaped. Invalid characters arrive as\xescapes, values can be up to 10,000 characters, characters XML 1.0 allows (non-Latin text, tab, line feed, carriage return and more) arrive as they are, and the element order changes.How it was checked
Tests were written first and fail on
rc.ReplacedStringTestcovers the escapes, the 10,000 limit (exactly 10,000 kept whole, 10,001 cut), a character made of a pair of surrogates at the limit kept whole with the next one cut, and a limit counted in characters (10,000 emoji kept, 10,001 cut). InShareUsageElementTests, the bad-schema test now looks forescapedand the escape, and three tests are new: invalid characters giveescapedand noreplacedortruncated, a 10,001 character value givestruncatedand noescapedwith 10,000 characters kept, and the element order follows the snippet with no CDATA node and noBadSchema.ShareUsageElementTestsfail on Ubuntu and WindowsReplacedStringTestand the bad-schema test fail on Java 8 and 21ReplacedStringTestand 25ShareUsageElementTestspass on Java 8 and 21Setting 'PullRequestSha'line is 5a356b7, the headmacOS was left out of this draft's full build under the 9 November decision. The rc head is built with macOS before it merges into main.
Every exit path of
writeXmlDatawas read after the change.Other open drafts
Draft #80 also changes the
ReplacedStringclass inShareUsageElement.java, to keep the characters XML 1.0 allows. This draft contains the same rule, so when both merge, the class from this draft is the one to keep. The merge needs a manual step in that class and inReplacedStringTest.What remains
Nothing for this record. The
pipeline/Gaps-vs-spec.mdfile is not edited here.