-
Notifications
You must be signed in to change notification settings - Fork 154
Allow RegularExpression for path match be RE2/PCRE friendly. #4450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the regular expression validation for pathType: RegularExpression to support PCRE-style patterns while maintaining RE2 compatibility, addressing user migration issues from nginx-ingress. The implementation switches from Go's standard regexp package to the regexp2 library, which provides Perl5-compatible regex support with RE2 compatibility mode.
Key Changes:
- Replaced restrictive RE2-only validation with regexp2-based validation supporting PCRE patterns
- Removed explicit bans on backreferences, lookarounds, and unescaped
$characters - Expanded test coverage to include PCRE-style patterns like named groups, lookaheads, and backreferences
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
go.mod |
Added github.com/dlclark/regexp2 v1.11.5 dependency for Perl5-compatible regex support |
internal/controller/nginx/config/validation/common.go |
Replaced regexp.Regexp with regexp2.Regexp, simplified validation logic by removing RE2-specific restrictions, updated documentation |
internal/controller/nginx/config/validation/common_test.go |
Expanded valid test cases to include PCRE patterns (lookaheads, backreferences, variable-width lookbehinds), removed previously-forbidden patterns from invalid test cases, added inline comments explaining test cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4450 +/- ##
=======================================
Coverage 86.05% 86.05%
=======================================
Files 132 132
Lines 14389 14382 -7
Branches 35 35
=======================================
- Hits 12383 12377 -6
+ Misses 1795 1791 -4
- Partials 211 214 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c591e11 to
440ae67
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bjee19
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice job
Proposed changes
Write a clear and concise description that helps reviewers understand the purpose and impact of your changes. Use the
following format:
Problem: Users had trouble specifying the PCRE style regex expressions when migrating from nginx-ingress
Solution: Use regexp2 to validate regular expression which is Perl5 library and ensure it is PCRE and RE2 friendly to avoid any breaking changes.
Testing: Manual testing, unit tests.
Testing with regular expressions from customer issues
cafe-route.yaml
config
regex with query params and headers regex -- multiple matches
Please focus on (optional): If you any specific areas where you would like reviewers to focus their attention or provide
specific feedback, add them here.
Closes #4409
Checklist
Before creating a PR, run through this checklist and mark each as complete.
Release notes
If this PR introduces a change that affects users and needs to be mentioned in the release notes,
please add a brief note that summarizes the change.