Skip to content

Parse JavaScript with Unicode-escaped identifiers - #510

Merged
swissspidy merged 1 commit into
mainfrom
claude/make-pot-escaped-identifiers
Oct 6, 2026
Merged

swissspidy merged 1 commit into
mainfrom
claude/make-pot-escaped-identifiers

Conversation

@swissspidy

Copy link
Copy Markdown
Member

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. main currently 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 \uXXXX or \u{…} escape for any character of a configured function name. It is treated like the existing eval exception.

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

  • New unit tests in tests/JsFunctionsScannerTest.php:
    • __(…) and _\u{78}(…) calls are extracted. This test fails without the fix.
    • Unrelated escapes such as '_a' and 'é' don't cause wrong extractions.
  • Suites: PHPUnit (68 tests) and features/makepot.feature (91 scenarios) pass locally.
  • Static checks: PHPCS and PHPStan are clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01D26yjkN2BiqCXT6p6o1WqS


Generated by Claude Code

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
@swissspidy
swissspidy requested a review from a team as a code owner October 6, 2026 16:52
Copilot AI balanced review requested due to automatic review settings October 6, 2026 16:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a8e87f86-7ca5-4861-8045-5138094554b8
📥 Commits

Reviewing files that changed from the base of the PR and between d47a013 and 1858f50.

📒 Files selected for processing (2)
  • src/JsFunctionsScanner.php
  • tests/JsFunctionsScannerTest.php
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added automated-pr bug command:i18n Related to 'i18n' command labels Oct 6, 2026
@swissspidy swissspidy added this to the 3.0.2 milestone Oct 6, 2026
@swissspidy
swissspidy merged commit ee11e2d into main Oct 6, 2026
64 checks passed
@swissspidy
swissspidy deleted the claude/make-pot-escaped-identifiers branch October 6, 2026 16:57
@codecov

codecov Bot commented Oct 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/JsFunctionsScanner.php 87.50% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-pr bug command:i18n Related to 'i18n' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants