[tor-commits] [metrics-lib/master] Remove redundant escape in regular expressions.
karsten at torproject.org
karsten at torproject.org
Mon Aug 27 12:33:54 UTC 2018
commit 18c5864591410eddf30a594fa7508cc7edb26ef4
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Mon Aug 20 20:51:19 2018 +0200
Remove redundant escape in regular expressions.
Turns out that characters inside square brackets don't need to be
escaped. In fact, "^[0-9\\.]{7,15}$" does not only match valid IPv4
addresses but also strings like "1\2\3\4".
---
src/main/java/org/torproject/descriptor/impl/ParseHelper.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/torproject/descriptor/impl/ParseHelper.java b/src/main/java/org/torproject/descriptor/impl/ParseHelper.java
index f196b2f..514bea8 100644
--- a/src/main/java/org/torproject/descriptor/impl/ParseHelper.java
+++ b/src/main/java/org/torproject/descriptor/impl/ParseHelper.java
@@ -44,7 +44,7 @@ public class ParseHelper {
return keyword;
}
- private static Pattern ipv4Pattern = Pattern.compile("^[0-9\\.]{7,15}$");
+ private static Pattern ipv4Pattern = Pattern.compile("^[0-9.]{7,15}$");
protected static String parseIpv4Address(String line, String address)
throws DescriptorParseException {
More information about the tor-commits
mailing list