Repository navigation
Parse JavaScript with Unicode-escaped identifiers - #510
Merged
Merged
Conversation
An identifier can be written with Unicode escapes, so `__( 'Hello' )` is a call to `__()` that doesn't contain the name itself, and the pre-check skipped it. Parse code fully when it contains an escape for any character of a translation function name. No JavaScript file in WooCommerce or Elementor contains such an escape. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D26yjkN2BiqCXT6p6o1WqS
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 36 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Follow-up to #509, which was merged before this fix was in.
#509 skips parsing JavaScript that doesn't contain a translation function name (
__,_x, …) as a whole word. In JavaScript, identifiers can be written with Unicode escapes, though, so__( 'Hello', 'foo-plugin' )is a call to__()that doesn't contain the name itself.maincurrently skips such a file, while the release before #509 extracted the string. CodeRabbit pointed this out in its review of #509.This parses the code fully, as before #509, when it contains a
\uXXXXor\u{…}escape for any character of a configured function name. It is treated like the existingevalexception.Impact on the speedup
None in practice: none of the 524 JavaScript files in WooCommerce or the 670 in Elementor contain such an escape, so the timings in #509 are unchanged.
Tests
tests/JsFunctionsScannerTest.php:__(…)and_\u{78}(…)calls are extracted. This test fails without the fix.'_a'and'é'don't cause wrong extractions.features/makepot.feature(91 scenarios) pass locally.🤖 Generated with Claude Code
https://claude.ai/code/session_01D26yjkN2BiqCXT6p6o1WqS
Generated by Claude Code