Skip to content

Conversation

justin-tay
Copy link
Collaborator

Closes #495

This updates the Joni and JDK RegularExpression to treat the $ anchor in the same way as ECMAScript.

This needed to update the pattern itself, namely replacing the $ anchor for \z The underlying issue being that the semantic meaning of $ for Joni and JDK is different from ECMAScript in that it allows trailing newlines. The meaning of \z is closer to what $ means for ECMAScript.

It's not possible for Joni to support this without changes to their code, this is actually determined in their Lexer. What is needed is AnchorType.END_BUF but for $ whether it's singleline or multiline only toggles between AnchorType.SEMI_END_BUF and AnchorType.END_LINE.

               case 'z':
                    if (syntax.opEscAZBufAnchor()) fetchTokenFor_anchor(AnchorType.END_BUF);
                    break;
                case '$':
                    if (syntax.opLineAnchor()) fetchTokenFor_anchor(isSingleline(env.option) ? AnchorType.SEMI_END_BUF : AnchorType.END_LINE);
                    break;

This also updates JDK RegularExpression to be able to accept the long form Unicode Character properties that ECMAScript also accepts.

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 81.48148% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.97%. Comparing base (48ca3c2) to head (357b27e).
⚠️ Report is 106 commits behind head on master.

Files with missing lines Patch % Lines
...com/networknt/schema/regex/RegularExpressions.java 81.06% 15 Missing and 10 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1201      +/-   ##
============================================
- Coverage     78.90%   77.97%   -0.93%     
+ Complexity     1965     1923      -42     
============================================
  Files           172      200      +28     
  Lines          6352     6730     +378     
  Branches       1255     1188      -67     
============================================
+ Hits           5012     5248     +236     
- Misses          867     1040     +173     
+ Partials        473      442      -31     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@stevehu stevehu merged commit 4dbdc9f into networknt:master Oct 20, 2025
4 checks passed
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.

PatternValidator does not correctly validate input with newlines

3 participants