Skip to content
Snippets Groups Projects
Commit 6010a1ec authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Disable Ignore/Highlight rules that have invalid patterns

parent ec53a966
No related branches found
No related tags found
No related merge requests found
Pipeline #308 failed
...@@ -3,6 +3,7 @@ package de.kuschku.libquassel.util ...@@ -3,6 +3,7 @@ package de.kuschku.libquassel.util
import de.kuschku.libquassel.util.compatibility.LoggingHandler.Companion.log import de.kuschku.libquassel.util.compatibility.LoggingHandler.Companion.log
import de.kuschku.libquassel.util.compatibility.LoggingHandler.LogLevel import de.kuschku.libquassel.util.compatibility.LoggingHandler.LogLevel
import java.io.Serializable import java.io.Serializable
import java.util.regex.PatternSyntaxException
class ExpressionMatch : Serializable { class ExpressionMatch : Serializable {
enum class MatchMode { enum class MatchMode {
...@@ -638,9 +639,12 @@ class ExpressionMatch : Serializable { ...@@ -638,9 +639,12 @@ class ExpressionMatch : Serializable {
* @param caseSensitive If true, match case-sensitively, otherwise ignore case when matching * @param caseSensitive If true, match case-sensitively, otherwise ignore case when matching
* @return Configured QRegularExpression * @return Configured QRegularExpression
*/ */
private fun regExFactory(regExString: String, caseSensitive: Boolean) = private fun regExFactory(regExString: String, caseSensitive: Boolean) = try {
if (caseSensitive) Regex(regExString) if (caseSensitive) Regex(regExString)
else Regex(regExString, RegexOption.IGNORE_CASE) else Regex(regExString, RegexOption.IGNORE_CASE)
} catch (e: PatternSyntaxException) {
null
}
/** /**
* Escapes any regular expression characters in a string so they have no special meaning * Escapes any regular expression characters in a string so they have no special meaning
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment