Skip to content

[4.x] Correct the StringHelper::compliant() docblock - #81

Open
Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-compliant-docblock
Open

Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-compliant-docblock

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

The docblock of StringHelper::compliant() said that it "will pass five and six octet UTF-8 sequences", that it is less strict than valid(), and that using it on user input lets attackers inject 5- and 6-byte sequences. That is wrong. compliant() relies on PCRE's /u validation, which rejects five- and six-octet sequences, overlong forms, surrogates, code points above U+10FFFF and incomplete sequences. The docblock now says that. The code does not change.

Testing Instructions

seedCompliantStrings, which feeds both testCompliant and testValid, gets a five-octet ("\xF8\x88\x80\x80\x80") and a six-octet sequence. Both methods reject them, before and after this PR. vendor/bin/phpunit is green, phpcs is clean, and PHPStan reports no errors locally. The PHPStan job in CI fails on 4.x-dev as well (mb_trim and the other PHP 8.4 polyfill functions are not found), and #66 fixes that.

Documentation Changes Required

None beyond the docblock. No docs page describes compliant().

Related to #75, which adds cases to the same data provider. They are on different lines, and a trial merge of the two branches is clean.

🤖 Generated with Claude Code

The docblock claimed that compliant() accepts five and six octet
sequences and is less strict than valid(). PCRE's UTF-8 validation
rejects them, as well as overlong forms, surrogates and incomplete
sequences.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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