Repository navigation
Keep submitted shortcodes and merge tags encoded on WordPress 7.2 (6.18.0) - #1974
Merged
jakejackson1 merged 5 commits intoOct 27, 2026
Merged
Conversation
Gravity PDF stops shortcodes and merge tags in submitted values being processed in a PDF by encoding [ ] { } as
[ ] { }. WordPress 7.2 rewrites wp_kses() on the HTML API, which decodes those character references,
so Kses::parse() turned them back into tags: a submitted {admin_email} printed the admin's address in the PDF. It
now forces kses' legacy parser while it runs, through the wp_kses_force_legacy_parser filter WordPress 7.2 adds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 tasks
…kses parser
Forcing kses' legacy parser only lasts as long as WordPress keeps the wp_kses_force_legacy_parser filter. encode_tags()
now puts an invisible word joiner (U+2060) after each [ { and : in the text instead of encoding [ ] { } as [ ]
{ }, which WordPress 7.2's HTML API kses decodes. Kses keeps the joiner on either parser, and it stops
shortcodes and merge tags matching. $form_data values get the same, and HTML attributes keep their URL-encoding.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…olon handling Same encode_tags() change as #1972. A zero-width no-break space (U+FEFF) replaces the word joiner, as mPDF strips it before drawing. Joiners now go on the whole value and come back out of attribute values, so text that only looks like a tag is covered, and an attribute's colons are neutralised so a merge tag opened in the text can't end inside one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… line Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…form_data changelog line Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 tasks
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.
Summary
Gravity PDF encodes
[ ] { }in submitted values as[ ] { }, so shortcodes and merge tags in them aren't processed in a PDF. The HTML then goes throughKses::parse(). WordPress 7.2 rebuildswp_kses()on the HTML API, which decodes those character references, soKses::parse()turned them back into real tags. On WordPress 7.2-beta1, a submitted{admin_email}printed the site admin's email address in the PDF, and a submitted[gravitypdf]shortcode printed a link. The 6.18 signing rules still kept those links unsigned.encode_tags()now puts a zero-width no-break space (U+FEFF) after each[,{and:instead. Kses keeps it on both parsers, it stops shortcodes and merge tags matching, and mPDF strips it before drawing, so the PDF shows the text as typed. HTML attributes keep their URL-encoding, and their colons are neutralised too, so a merge tag opened in the text can't end inside one.$form_datavalues get the same.Try it
{admin_email} [gravitypdf id="<PDF ID>"].Test plan
yarn test:php -- --filter 'test_encode_tags|test_html_structure_keeps_user_tags_encoded'More info
development. It replaces the second commit's word joiner (U+2060), which replaced the first commit'swp_kses_force_legacy_parserswitch.:too: Gravity Forms' field merge tags ({Label:1},{Label:1:value},{:1}) and Gravity PDF's{Label:pdf:ID}allow any text after{, so a joiner there alone doesn't stop them.I <3 {admin_email} >_<, is covered too.[ ] { }are URL-encoded as before. A colon gets%3Ain a URL after the scheme, stays as a style declaration's property colon, and gets the joiner anywhere else. Without this, a rich-text value like{x <b title=":3:">}printed field 3's value. The second commit did that on current WordPress too, which RC3 didn't.[ ] { }don't change.$form_datavalues are plain text, so a URL there that contains brackets also gets a joiner afterhttps:. It prints the same, but a custom template that uses it as a link would need to strip U+FEFF.[ ] { }, a link with a port, likehttps://example.org:8080/, gets%3Afor the port's colon, which breaks the link.test_encode_tagscovers 11 cases. Each is checked encoded twice, and against Gravity PDF's and Gravity Forms' merge tag patterns after kses.test_default_tags_are_restored_in_attributesis new.test_html_structure_keeps_user_tags_encodedruns on both kses parsers, and now coversI <3 {admin_email} >_<./on mPDF's self-closing tags,"in text), and fail on RC3 too.{admin_email}, field tags,{Doc:pdf:ID},[gravitypdf]) and a forged rich-text entry with the attribute cases print as typed. No admin email, PDF link or other field's value appears.$form_dataDeveloper line now names U+FEFF.🤖 Generated with AI