jabref icon indicating copy to clipboard operation
jabref copied to clipboard

Symbols in search produce regex PatternSyntaxException exceptions

Open ryan-carpenter opened this issue 3 months ago • 21 comments

JabRef version

Latest development branch build (please note build date below)

Operating system

macOS

Details on version and operating system

JabRef 100.0.0 Mac OS X 26.5.2 aarch64 Java 25.0.3 JavaFX 26.0.2+3

Checked with the latest development build (copy version output from About dialog)

  • [x] I made a backup of my libraries before testing the latest development version.
  • [x] I have tested the latest development version and the problem persists

Steps to reproduce the behaviour

  1. Click on the search box
  2. type *, fieldname=*, or fieldname=~* (see more examples below)
  3. Notice uncaught exception
Exception Character Example Note
Dangling meta character *, + *, fieldname=*, fieldname=~* Wants .*, anything+
Illegal repetition { anything{ Wants {2}, {3}
Unclosed character class [ anything[ Wants [ ... ]
Unclosed group \ fieldname=~^\, fieldname=~\ Wants \w, \s, etc.

There appear to be two problems:

  • Exceptions occur when a regular expression is incomplete. Instead this should trigger a validation warning, like the red highlight that happens when a search is empty.
  • Exceptions related to regular expressions occur when regex searching is not enabled. The search string should only be treated as a regular expression when the .* UI button is depressed or when the string includes the =~ operator.

Edit: Clarified the description, updated the issue title to match, added logs and detail about conditions that trigger exceptions. Edit: Added OS and version details.

Appendix

...

Log File
java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 5
(?i)(*)
     ^
	at java.base/java.util.regex.Pattern.error(Pattern.java:2205)
	at java.base/java.util.regex.Pattern.sequence(Pattern.java:2380)
	at java.base/java.util.regex.Pattern.expr(Pattern.java:2246)
	at java.base/java.util.regex.Pattern.group0(Pattern.java:3230)
	at java.base/java.util.regex.Pattern.sequence(Pattern.java:2301)
	at java.base/java.util.regex.Pattern.expr(Pattern.java:2246)
	at java.base/java.util.regex.Pattern.compile(Pattern.java:1946)
	at java.base/java.util.regex.Pattern.<init>(Pattern.java:1577)
	at java.base/java.util.regex.Pattern.compile(Pattern.java:1102)
	at java.base/java.lang.String.replaceAll(String.java:3134)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightNode(Highlighter.java:70)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightTextNodes(Highlighter.java:59)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightTextNodes(Highlighter.java:63)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightTextNodes(Highlighter.java:63)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightHtml(Highlighter.java:52)
	at org.jabref/org.jabref.gui.preview.PreviewViewer.getHighlightedLayoutText(PreviewViewer.java:301)
	at org.jabref/org.jabref.gui.preview.PreviewViewer.lambda$highlightLayoutText$0(PreviewViewer.java:282)
	at [email protected]/com.sun.javafx.application.PlatformImpl.lambda$runLater$0(PlatformImpl.java:424)
	at [email protected]/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)

java.util.regex.PatternSyntaxException: Illegal repetition near index 6
(?i)({)
      ^
	at java.base/java.util.regex.Pattern.error(Pattern.java:2205)
	at java.base/java.util.regex.Pattern.closure(Pattern.java:3488)
	at java.base/java.util.regex.Pattern.sequence(Pattern.java:2391)
	at java.base/java.util.regex.Pattern.expr(Pattern.java:2246)
	at java.base/java.util.regex.Pattern.group0(Pattern.java:3230)
	at java.base/java.util.regex.Pattern.sequence(Pattern.java:2301)
	at java.base/java.util.regex.Pattern.expr(Pattern.java:2246)
	at java.base/java.util.regex.Pattern.compile(Pattern.java:1946)
	at java.base/java.util.regex.Pattern.<init>(Pattern.java:1577)
	at java.base/java.util.regex.Pattern.compile(Pattern.java:1102)
	at java.base/java.lang.String.replaceAll(String.java:3134)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightNode(Highlighter.java:70)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightTextNodes(Highlighter.java:59)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightTextNodes(Highlighter.java:63)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightTextNodes(Highlighter.java:63)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightHtml(Highlighter.java:52)
	at org.jabref/org.jabref.gui.preview.PreviewViewer.getHighlightedLayoutText(PreviewViewer.java:301)
	at org.jabref/org.jabref.gui.preview.PreviewViewer.lambda$highlightLayoutText$0(PreviewViewer.java:282)
	at [email protected]/com.sun.javafx.application.PlatformImpl.lambda$runLater$0(PlatformImpl.java:424)
	at [email protected]/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)

java.util.regex.PatternSyntaxException: Unclosed character class near index 6
(?i)([)
      ^
	at java.base/java.util.regex.Pattern.error(Pattern.java:2205)
	at java.base/java.util.regex.Pattern.clazz(Pattern.java:2870)
	at java.base/java.util.regex.Pattern.sequence(Pattern.java:2316)
	at java.base/java.util.regex.Pattern.expr(Pattern.java:2246)
	at java.base/java.util.regex.Pattern.group0(Pattern.java:3230)
	at java.base/java.util.regex.Pattern.sequence(Pattern.java:2301)
	at java.base/java.util.regex.Pattern.expr(Pattern.java:2246)
	at java.base/java.util.regex.Pattern.compile(Pattern.java:1946)
	at java.base/java.util.regex.Pattern.<init>(Pattern.java:1577)
	at java.base/java.util.regex.Pattern.compile(Pattern.java:1102)
	at java.base/java.lang.String.replaceAll(String.java:3134)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightNode(Highlighter.java:70)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightTextNodes(Highlighter.java:59)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightTextNodes(Highlighter.java:63)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightTextNodes(Highlighter.java:63)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightHtml(Highlighter.java:52)
	at org.jabref/org.jabref.gui.preview.PreviewViewer.getHighlightedLayoutText(PreviewViewer.java:301)
	at org.jabref/org.jabref.gui.preview.PreviewViewer.lambda$highlightLayoutText$0(PreviewViewer.java:282)
	at [email protected]/com.sun.javafx.application.PlatformImpl.lambda$runLater$0(PlatformImpl.java:424)
	at [email protected]/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)

java.util.regex.PatternSyntaxException: Unclosed group near index 7
(?i)(\)
	at java.base/java.util.regex.Pattern.error(Pattern.java:2205)
	at java.base/java.util.regex.Pattern.accept(Pattern.java:2055)
	at java.base/java.util.regex.Pattern.group0(Pattern.java:3233)
	at java.base/java.util.regex.Pattern.sequence(Pattern.java:2301)
	at java.base/java.util.regex.Pattern.expr(Pattern.java:2246)
	at java.base/java.util.regex.Pattern.compile(Pattern.java:1946)
	at java.base/java.util.regex.Pattern.<init>(Pattern.java:1577)
	at java.base/java.util.regex.Pattern.compile(Pattern.java:1102)
	at java.base/java.lang.String.replaceAll(String.java:3134)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightNode(Highlighter.java:70)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightTextNodes(Highlighter.java:59)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightTextNodes(Highlighter.java:63)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightTextNodes(Highlighter.java:63)
	at org.jabref/org.jabref.gui.search.Highlighter.highlightHtml(Highlighter.java:52)
	at org.jabref/org.jabref.gui.preview.PreviewViewer.getHighlightedLayoutText(PreviewViewer.java:301)
	at org.jabref/org.jabref.gui.preview.PreviewViewer.lambda$highlightLayoutText$0(PreviewViewer.java:282)
	at [email protected]/com.sun.javafx.application.PlatformImpl.lambda$runLater$0(PlatformImpl.java:424)
	at [email protected]/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)

ryan-carpenter avatar Aug 12 '26 07:08 ryan-carpenter

/assign-me

fulluhere avatar Aug 15 '26 06:08 fulluhere

👋 Hey @fulluhere, thank you for your interest in this issue! 🎉

We're excited to have you on board. Start by exploring our Contributing guidelines, and set up your local development workspace by following the steps in our workspace setup guidelines to get started smoothly.

For questions on JabRef functionality, you can consult the JabRef Guru. For questions related to the codebase, please start using DeepWiki.

In case you encounter failing tests during development, please check our developer FAQs!

Still facing issues or having more questions? Feel free to ask here on GitHub or on JabRef's Gitter chat. Please don't hesitate to open a (draft) pull request early on to show the direction you are heading towards if unsure.

Happy coding! 🚀

jabref-machine avatar Aug 15 '26 06:08 jabref-machine

Similar to https://github.com/JabRef/jabref/issues/14632

subhramit avatar Aug 17 '26 21:08 subhramit

/assign-me

thesauravpoddar avatar Aug 18 '26 07:08 thesauravpoddar

⚠️ Assignment Limit Reached

Hi @thesauravpoddar, you've already reached the limit of 2 active assignments. Issues are a great way to work on opensource, and we want to ensure that all contributors have the opportunity to work on issues.

jabref-machine avatar Aug 18 '26 07:08 jabref-machine

Pardon for inconvenience i did not notice this, earlier limit was 3 that's why i tried to take this

thesauravpoddar avatar Aug 18 '26 07:08 thesauravpoddar

Pardon for inconvenience i did not notice this, earlier limit was 3 that's why i tried to take this

Apart from the "active" assignment limit, we intend to keep "good first issue"s for newcomers to JabRef. You can look for good second issues and so on.

subhramit avatar Aug 18 '26 08:08 subhramit

Pardon for inconvenience i did not notice this, earlier limit was 3 that's why i tried to take this

Apart from the "active" assignment limit, we intend to keep "good first issue"s for newcomers to JabRef. You can look for good second issues and so on.

Okayy

thesauravpoddar avatar Aug 18 '26 09:08 thesauravpoddar

👋 Hey @Prabal864, thank you for your interest in this issue! 🎉

We're excited to have you on board. Start by exploring our Contributing guidelines, and set up your local development workspace by following the steps in our workspace setup guidelines to get started smoothly.

For questions on JabRef functionality, you can consult the JabRef Guru. For questions related to the codebase, please start using DeepWiki.

In case you encounter failing tests during development, please check our developer FAQs!

Still facing issues or having more questions? Feel free to ask here on GitHub or on JabRef's Gitter chat. Please don't hesitate to open a (draft) pull request early on to show the direction you are heading towards if unsure.

Happy coding! 🚀

jabref-machine avatar Aug 18 '26 15:08 jabref-machine

/assign-me

Prabal864 avatar Aug 18 '26 15:08 Prabal864

/assign-me

aakankshadasagi avatar Aug 18 '26 20:08 aakankshadasagi

👋 Hey @aakankshadasagi, thank you for your interest in this issue! 🎉

We're excited to have you on board. Start by exploring our Contributing guidelines, and set up your local development workspace by following the steps in our workspace setup guidelines to get started smoothly.

For questions on JabRef functionality, you can consult the JabRef Guru. For questions related to the codebase, please start using DeepWiki.

In case you encounter failing tests during development, please check our developer FAQs!

Still facing issues or having more questions? Feel free to ask here on GitHub or on JabRef's Gitter chat. Please don't hesitate to open a (draft) pull request early on to show the direction you are heading towards if unsure.

Happy coding! 🚀

jabref-machine avatar Aug 18 '26 20:08 jabref-machine

⏰ Assignment Reminder

Hi @aakankshadasagi, this is a friendly reminder about your assignment to this issue.

[!WARNING] This issue will be automatically unassigned in 4 days if there's no activity.

Remember that you can ask the JabRef Guru or DeepWiki about anything regarding JabRef. Additionally, our contributing guide has hints on creating a pull request and a link to our Gitter chat.

How to keep your assignment


If you are working on it, you can prevent automatic unassignment by:

  • Submitting a draft pull request with your progress within 4 days
  • Asking for the 📌 Pinned label if you need more time

We appreciate your contribution and are here to help if needed!

github-actions[bot] avatar Aug 22 '26 12:08 github-actions[bot]

/assign-me

Prabal864 avatar Aug 22 '26 12:08 Prabal864

⚠️ Issue Already Assigned

Hi @Prabal864, this issue is currently assigned to @aakankshadasagi.

[!NOTE] If no progress is made within 8 days, the issue will be automatically unassigned.

Options for contributors
  • Wait for availability: The issue may become available if auto-unassigned
  • Collaborate: You can ask the assignee if they want help
  • Maintainer assistance: A maintainer can add you as co-assignee if appropriate

jabref-machine avatar Aug 22 '26 12:08 jabref-machine

📋 Assignment Update

Hi @aakankshadasagi, due to inactivity, you have been unassigned from this issue.

Next steps


If you still want to work on this:

  • Submit a pull request showing your current state. You will be automatically assigned again.
  • Ask a maintainer to assign you again.

github-actions[bot] avatar Aug 29 '26 12:08 github-actions[bot]

/assign-me

Prabal864 avatar Aug 29 '26 15:08 Prabal864

Thank you for your continued work in JabRef. At this point, you probably already know the basics and the important links. If not, our contributing guidelines is the place you should go to.

At this point in time, you raised 2 pull request(s) of which 50% (1/2) have been merged.

jabref-machine avatar Aug 29 '26 15:08 jabref-machine

⏰ Assignment Reminder

Hi @Prabal864, this is a friendly reminder about your assignment to this issue.

[!WARNING] This issue will be automatically unassigned in 4 days if there's no activity.

Remember that you can ask the JabRef Guru or DeepWiki about anything regarding JabRef. Additionally, our contributing guide has hints on creating a pull request and a link to our Gitter chat.

How to keep your assignment


If you are working on it, you can prevent automatic unassignment by:

  • Submitting a draft pull request with your progress within 4 days
  • Asking for the 📌 Pinned label if you need more time

We appreciate your contribution and are here to help if needed!

github-actions[bot] avatar Sep 02 '26 12:09 github-actions[bot]

This is not a good first issue. Will be taken up by the internal team.

subhramit avatar Sep 05 '26 01:09 subhramit