Remove support for escape characters from glob patterns

I thought it'd be nice to ensure we could represent any character in the
patterns. However, this isn't required (as the client only uses
alphabetical class, method and field names). Furthermore, the period
character is already unusable in class names due to the MemberRef string
parsing.

Signed-off-by: Graham <gpe@openrs2.dev>
Graham 5 years ago
parent e13cc5b47e
commit 2a4d607d96
  1. 11
      asm/src/main/java/dev/openrs2/asm/filter/Glob.kt

@ -12,11 +12,8 @@ object Glob {
private fun compile(pattern: String, className: Boolean): Regex {
val regex = StringBuilder()
var star = false
var escape = false
for (ch in pattern) {
check(!star || !escape)
if (star) {
star = false
@ -26,9 +23,6 @@ object Glob {
}
regex.append("[^/]*")
} else if (escape) {
regex.append(Regex.escape(ch.toString()))
continue
}
when (ch) {
@ -37,7 +31,6 @@ object Glob {
} else {
regex.append(".*")
}
'\\' -> escape = true
else -> regex.append(Regex.escape(ch.toString()))
}
}
@ -46,10 +39,6 @@ object Glob {
regex.append(".*")
}
require(!escape) {
"Unterminated escape sequence"
}
return Regex(regex.toString())
}
}

Loading…
Cancel
Save