[sip-comm-dev] History search java.util.regex.PatternSyntaxException


#1

Hi,

I was playing with the history (this is a full time job for me these days:))) ) and when trying to search with " kak vurvi******* " the following exception appeared:

     [java] Exception in thread "Thread-22" java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 17
     [java] ^(?i).*kak vurvi********.*$
     [java] ^
     [java] at java.util.regex.Pattern.error(Pattern.java:1650)
     [java] at java.util.regex.Pattern.sequence(Pattern.java:1787)
     [java] at java.util.regex.Pattern.expr(Pattern.java:1687)
     [java] at java.util.regex.Pattern.compile(Pattern.java:1397)
     [java] at java.util.regex.Pattern.<init>(Pattern.java:1124)
     [java] at java.util.regex.Pattern.compile(Pattern.java:817)
     [java] at java.util.regex.Pattern.matches(Pattern.java:919)
     [java] at java.lang.String.matches(String.java:1921)
     [java] at net.java.sip.communicator.impl.history.HistoryReaderImpl.matchKeyword(HistoryReaderImpl.java:467)
     [java] at net.java.sip.communicator.impl.history.HistoryReaderImpl.filterByKeyword(HistoryReaderImpl.java:420)
     [java] at net.java.sip.communicator.impl.history.HistoryReaderImpl.find(HistoryReaderImpl.java:337)
     [java] at net.java.sip.communicator.impl.history.HistoryReaderImpl.findByKeywords(HistoryReaderImpl.java:264)
     [java] at net.java.sip.communicator.impl.history.HistoryReaderImpl.findByKeyword(HistoryReaderImpl.java:246)
     [java] at net.java.sip.communicator.impl.msghistory.MessageHistoryServiceImpl.findByKeyword(MessageHistoryServiceImpl.java:702)
     [java] at net.java.sip.communicator.impl.msghistory.MessageHistoryServiceImpl.findByKeyword(MessageHistoryServiceImpl.java:226)
     [java] at net.java.sip.communicator.impl.gui.main.message.history.HistoryWindow$KeywordDatesLoader.run(HistoryWindow.java:560)

I think it could be because the special characters are not escaped when making the regular expression. I have made myself a method that do that, but it's in the gui package. If really this is the problem causing that exception and if this could be a common task we could think about making a general method in the util package. Or maybe it's already there?

Regards,
Yana

···

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#2

Hi Yana,

Yana Stamcheva wrote:

If really this is the problem causing that exception and if this could be a common task we could think about making a general method in the util package. Or maybe it's already there?

OK. If Damian also needs it you should indeed put it in util.

Emil