Skip to content

HybridParser now ends shortcode names at syntax tokens - #130

Merged
thunderer merged 1 commit into
masterfrom
tk-hybrid-names
Nov 7, 2026
Merged

thunderer merged 1 commit into
masterfrom
tk-hybrid-names

Conversation

@thunderer

Copy link
Copy Markdown
Owner

HybridParser matched shortcode names with a fixed character list, so with a syntax that uses -, * or _ as a token, the name took that token too: with - as the marker, [a-] gave the name a- with HybridParser and a with RegularParser. HybridParser is not in any tag yet, so this changes nothing for released versions.

  • names now stop at any syntax token, the same way as string tokens,
  • added a test that runs on both parsers and fails on master,
  • verified that HybridParser matches RegularParser on 20000 random texts for each of 6 syntaxes that use -, * or _ as a token, from 6500-12700 differences to 0 on PHP 5.5-8.5,
  • verified the same HybridParser output as master with the default and {} syntaxes on PHP 5.5-8.5,
  • verified PHPUnit on PHP 5.5-8.5, Psalm on PHP 7.4-8.5, Mago and Infection.

With JIT the speed is the same: 1MB of text takes 24.5ms before and 23.9ms after on PHP 8.4. Without JIT, on text made only of long names, 1MB takes 29ms before and 74ms after on PHP 8.4, and 182ms and 218ms on PHP 5.6.

Without JIT, a name of 200000 characters or more now fails with PCRE error 2, the same as in RegularParser. With JIT, a name of 1000000 characters still parses, and an unclosed one no longer fails.

@thunderer
thunderer merged commit 5fbd7df into master Nov 7, 2026
16 checks passed
@thunderer
thunderer deleted the tk-hybrid-names branch November 7, 2026 21:28
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