Skip to content

Conversation

@koppor
Copy link
Member

@koppor koppor commented Dec 27, 2025

User description

@LoayGhreeb I found this in my local branches. Do you think, it makes sence?

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • [/] I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • [/] I described the change in CHANGELOG.md in a way that is understandable for the average user (if change is visible to the user)
  • [/] I checked the user documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request updating file(s) in https://github.com/JabRef/user-documentation/tree/main/en.

PR Type

Documentation


Description

  • Add TODO comments about missing unescaping logic

  • Document that field escaping doesn't work as expected

  • Clarify Lucene field validation behavior in comments


Diagram Walkthrough

flowchart LR
  A["Search Query Processing"] --> B["Multiple Visitor Classes"]
  B --> C["SearchQueryExtractorVisitor"]
  B --> D["SearchQueryVisitor"]
  B --> E["SearchToLuceneVisitor"]
  B --> F["SearchToSqlVisitor"]
  C --> G["Add TODO: Missing Unescaping"]
  D --> G
  E --> G
  E --> H["Document isValidField Logic"]
  F --> G
Loading

File Walkthrough

Relevant files
Documentation
SearchQueryExtractorVisitor.java
Add TODO for missing field term unescaping                             

jablib/src/main/java/org/jabref/logic/search/query/SearchQueryExtractorVisitor.java

  • Added TODO comment about missing unescaping of field terms
  • Notes that escaped field names like field\=thing=value don't work as
    expected
+1/-0     
SearchQueryVisitor.java
Add TODO for missing field term unescaping                             

jablib/src/main/java/org/jabref/logic/search/query/SearchQueryVisitor.java

  • Added TODO comment about missing unescaping of field terms
  • Notes that escaped field names like field\=thing=value don't work as
    expected
+1/-0     
SearchToLuceneVisitor.java
Add TODO and document field validation logic                         

jablib/src/main/java/org/jabref/logic/search/query/SearchToLuceneVisitor.java

  • Added TODO comment about missing unescaping of field terms
  • Added documentation comments explaining isValidField method behavior
  • Clarifies that Lucene index only stores file metadata, not BibEntry
    fields like author
+4/-0     
SearchToSqlVisitor.java
Add TODO for missing field term unescaping                             

jablib/src/main/java/org/jabref/logic/search/query/SearchToSqlVisitor.java

  • Added TODO comment about missing unescaping of field terms
  • Notes that escaped field names like field\=thing=value don't work as
    expected
+1/-0     

@qodo-free-for-open-source-projects
Copy link
Contributor

qodo-free-for-open-source-projects bot commented Dec 27, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-free-for-open-source-projects
Copy link
Contributor

qodo-free-for-open-source-projects bot commented Dec 27, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Unescape field names before use

To fix incorrect field matching, unescape the field name before use. Add a new
method unescapeFieldName to SearchQueryConversion for this purpose and apply it
to ctx.FIELD().getText().

jablib/src/main/java/org/jabref/logic/search/query/SearchQueryExtractorVisitor.java [101-102]

-// TODO: Here, there us no unescapeing of the term (e.g., field\=thing=value does not work as expected)
-String field = ctx.FIELD().getText().toLowerCase(Locale.ROOT);
+String field = SearchQueryConversion.unescapeFieldName(ctx.FIELD().getText()).toLowerCase(Locale.ROOT);
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: The suggestion provides a concrete fix for a bug that the PR author only marked with a TODO, improving the search functionality by correctly handling escaped characters in field names.

Medium
Learned
best practice
Fix typos in TODO comment
Suggestion Impact:The suggestion was partially implemented. The commit fixed both typos ("us" to "is" and "unescapeing" to "unescaping") as suggested, but also made an additional change by replacing "term" with "field" at the end of the comment.

code diff:

-        // TODO: Here, there us no unescapeing of the term (e.g., field\=thing=value does not work as expected)
+        // TODO: Here, there is no unescaping of the field (e.g., field\=thing=value does not work as expected)

Fix the typo "us" to "is" and "unescapeing" to "unescaping" in the TODO comment
for clarity and professionalism.

jablib/src/main/java/org/jabref/logic/search/query/SearchQueryExtractorVisitor.java [101]

-// TODO: Here, there us no unescapeing of the term (e.g., field\=thing=value does not work as expected)
+// TODO: Here, there is no unescaping of the term (e.g., field\=thing=value does not work as expected)

[Suggestion processed]

Suggestion importance[1-10]: 6

__

Why:
Relevant best practice - Correct typographical errors in code comments to maintain code quality and professionalism

Low
  • Update

LoayGhreeb
LoayGhreeb previously approved these changes Dec 27, 2025
Copy link
Member

@LoayGhreeb LoayGhreeb left a comment

Choose a reason for hiding this comment

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

Looks valid. I assumed that the field names would not contain special characters (=, !, ~, (, )), but we should consider it if the parser's reserved special characters are allowed in the field names.

We might also open an issue for this, it could be a good first issue.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants