Fix month checker regex#15678
Conversation
Review Summary by QodoAdd regex anchors to enforce exact month validation
WalkthroughsDescription• Add regex anchors (^ and $) to MonthChecker patterns • Enforce exact string matching for month validation • Prevent malformed partial matches from passing validation • Update CHANGELOG.md documenting the fix Diagramflowchart LR
A["MonthChecker Regex Patterns"] -->|Add anchors ^ and $| B["Exact String Matching"]
B -->|Reject| C["Partial Matches"]
B -->|Accept| D["Valid Months"]
File Changes1. jablib/src/main/java/org/jabref/logic/integrity/MonthChecker.java
|
Code Review by Qodo
1.
|
|
Please address Qodo comments |
|
If possible, please also add a test. |
|
updated the regex to allow zero-padded months (01-09) as suggested by Qodo and added regression tests in MonthCheckerTest.java |
|
|
||
| @Test | ||
| void checkValueAcceptsZeroPaddedMonths() { | ||
| // Confirms that the optional zero (0?) in the regex works for Biblatex mode |
|
|
||
| @Test | ||
| void checkValueDoesNotAcceptPartialMatches() { | ||
| assertEquals(Optional.of(Localization.lang("should be an integer or normalized")), |
There was a problem hiding this comment.
-
Revert the format change
-
Localization.langis not necessary
|
Please disclose AI uasge in this PR. |
|
Added AI Disclosure to PR description. |
|
LGTM |
* upstream/main: (21 commits) chore(deps): update dependency com.konghq:unirest-modules-gson to v4.10.0 (JabRef#15715) Add manual tests (JabRef#15351) Refactored the comments for UnlinkedFilesCrawler (JabRef#15709) Replace inline styles with CSS classes (JabRef#15694) add test case for multiple authors in csl citaiton (JabRef#15707) fix invalid desktop file for linux (JabRef#15702) Change FileKeystore and Folder fields to disable/enable (JabRef#15685) Chore(deps): Bump org.openrewrite.recipe:rewrite-recipe-bom from 3.30.0 to 3.30.1 (JabRef#15696) New Crowdin updates (JabRef#15693) Chore(deps): Bump dev.langchain4j:langchain4j-bom in /versions (JabRef#15698) Chore(deps): Bump org.apache.logging.log4j:log4j-to-slf4j in /versions (JabRef#15700) chore(deps): update dependency org.apache.logging.log4j:log4j-to-slf4j to v2.26.0 (JabRef#15699) Chore(deps): Bump org.openrewrite.rewrite from 7.32.1 to 7.32.2 (JabRef#15697) Chore(deps): Bump jablib/src/main/resources/csl-locales (JabRef#15689) Fix month checker regex (JabRef#15678) Chore(deps): Bump com.dlsc.gemsfx:gemsfx in /versions (JabRef#15692) Chore(deps): Bump org.hisp.dhis:json-tree in /versions (JabRef#15691) Chore(deps): Bump jablib/src/main/resources/csl-styles (JabRef#15690) New Crowdin updates (JabRef#15687) Chore(deps): Bump com.konghq:unirest-java-core in /versions (JabRef#15683) ...
Related issues and pull requests
Closes #15577
#15577
PR Description
This PR updates the MonthChecker validation logic by adding start (^) and end ($) anchors to the underlying regular expressions. This change enforces exact string matching for month values, ensuring that only valid integers (1-12) or normalized BibTeX strings are accepted while preventing malformed partial matches from passing the validation layer.
Steps to test
AI Disclosure
I utilized Google Gemini to help troubleshoot local Gradle build environment issues and assist in drafting JUnit test structure for this PR. All logic was manually verified and tested against the JabRef contribution guidelines.
Checklist
CHANGELOG.mdin a way that can be understood by the average user (if change is visible to the user)