Repository navigation
Normalize text domain string in make-json command - #498
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe JSON generation command now removes unsafe characters from effective translation domains before creating filenames. End-to-end coverage verifies domains from PO headers and CLI arguments produce files within the destination directory. ChangesDomain filename sanitization
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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 |
There was a problem hiding this comment.
Pull request overview
This PR hardens the wp i18n make-json command by ensuring the text domain used in output JSON filenames is normalized to a safe character set, preventing domains sourced from PO headers or CLI args from producing unsafe/undesired paths.
Changes:
- Sanitize the effective
$domaininMakeJsonCommand::make_json()by stripping non-alphanumeric / non-hyphen characters before it is used to prefix the output base filename. - Add a Behat scenario that verifies normalization for both the
X-DomainPO header and the--domainCLI argument, including asserting no file is created outside the intended destination directory.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/MakeJsonCommand.php | Normalizes/sanitizes the domain string before using it in the JSON output base filename. |
| features/makejson.feature | Adds acceptance coverage ensuring unsafe domains from headers/flags are normalized and do not escape the destination path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Applying some slight hardening
Summary by CodeRabbit