Prefer re2 over java.util.regex

Java's stock regex implementation doesn't guarantee linear time
complexity which makes it a security liability.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=121159875
This commit is contained in:
jart 2016-04-29 15:54:39 -07:00 committed by Justine Tunney
parent 3291eb8b70
commit 6082146d55
42 changed files with 64 additions and 39 deletions

View file

@ -17,7 +17,6 @@ java_library(
"//java/com/google/common/io",
"//java/com/google/common/net",
"//java/google/registry/model",
"//java/google/registry/security",
"//java/google/registry/ui",
"//java/google/registry/ui/forms",
"//java/google/registry/util",
@ -25,6 +24,7 @@ java_library(
"//third_party/java/joda_time",
"//third_party/java/json_simple",
"//third_party/java/jsr305_annotations",
"//third_party/java/re2j",
"//third_party/java/servlet/servlet_api",
"//third_party/closure/templates",

View file

@ -23,6 +23,7 @@ import com.google.common.base.Function;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import com.google.common.net.InternetDomainName;
import com.google.re2j.Pattern;
import google.registry.model.registrar.Registrar;
import google.registry.model.registrar.RegistrarAddress;
@ -37,7 +38,6 @@ import java.security.cert.CertificateParsingException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
@ -45,7 +45,7 @@ import javax.annotation.Nullable;
public final class RegistrarFormFields {
public static final Pattern BASE64_PATTERN = Pattern.compile("[+/a-zA-Z0-9]*");
public static final Pattern ASCII_PATTERN = Pattern.compile("\\p{ASCII}*");
public static final Pattern ASCII_PATTERN = Pattern.compile("[[:ascii:]]*");
public static final String ASCII_ERROR = "Please only use ASCII-US characters.";
private static final Function<String, CidrAddressBlock> CIDR_TRANSFORM =

View file

@ -25,6 +25,8 @@ import com.google.common.base.Splitter;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.Resources;
import com.google.re2j.Matcher;
import com.google.re2j.Pattern;
import com.google.template.soy.SoyFileSet;
import com.google.template.soy.SoyUtils;
import com.google.template.soy.base.SoySyntaxException;
@ -40,8 +42,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** Helper methods for rendering Soy templates from Java code. */
public final class SoyTemplateUtils {

View file

@ -16,6 +16,7 @@ java_library(
"//java/com/google/common/collect",
"//java/com/google/common/io",
"//java/com/google/common/net",
"//third_party/java/re2j",
"//java/google/registry/braintree",
"//java/google/registry/config",
"//java/google/registry/export/sheet",

View file

@ -23,6 +23,7 @@ import static java.util.Arrays.asList;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.re2j.Pattern;
import com.braintreegateway.BraintreeGateway;
import com.braintreegateway.Result;
@ -49,7 +50,6 @@ import java.math.BigDecimal;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern;
import javax.inject.Inject;