Skip to content

Escape names already starting with prefix in Base64NameProcessor - #886

Open
Sahana2524 wants to merge 1 commit into
FasterXML:3.xfrom
Sahana2524:base64-name-prefix-escape
Open

Escape names already starting with prefix in Base64NameProcessor#886
Sahana2524 wants to merge 1 commit into
FasterXML:3.xfrom
Sahana2524:base64-name-prefix-escape

Conversation

@Sahana2524

Copy link
Copy Markdown
Contributor

The prefixed base64 name processor escapes on write but decodes on read using different conditions, so a name that already starts with the prefix does not survive a round-trip:

  • encodeName() escapes only names that fail VALID_XML_NAME, so base64_tag_YWRtaW4 is a valid XML name and goes out as-is
  • decodeName() decodes anything starting with the prefix, so that same name reads back as admin
  • when the remainder is not valid base64 (base64_tag_hello) the read fails instead, which is how I noticed it

Escaping prefixed names too makes the decode-side prefix test exact, so the mapping is one-to-one again. Names that do not start with the prefix encode exactly as before. The javadoc had this as a caller obligation ("you must ensure that no incoming element or attribute name starts with prefix") - that seemed worth moving into the processor, since with map keys the names are usually not the caller's to choose. Left AlwaysOnBase64NameProcessor alone: it encodes and decodes every name, so it is already symmetric.

encodeName() escaped only names that were not valid XML names, but decodeName() base64-decodes anything carrying the prefix, so a valid name already starting with it did not survive a round-trip.
@github-actions

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 73.64% 📈 +0.010%
Branches branches 68.44% 📈 +0.040%

Coverage data generated from JaCoCo test results

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.

1 participant