diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-03-07 16:50:58 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-03-07 16:50:59 +0000 |
commit | d0f092af8494a0921317219b9b001ec8aa6d741c (patch) | |
tree | d334a01de79a031fd94e377dc5815b5b9bd0ea95 | |
parent | 8328f27a87577581be640f80918fe4c6251ac881 (diff) | |
parent | 7f8466fab49f684ec3f430d15ae765d3886052c5 (diff) | |
download | base-o-preview.tar.gz |
Merge "Framework: Ensure image heap string literals for Patterns"android-o-preview-1o-preview
-rw-r--r-- | core/java/android/util/Patterns.java | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/core/java/android/util/Patterns.java b/core/java/android/util/Patterns.java index 0a452dbc39a1..86434b26058b 100644 --- a/core/java/android/util/Patterns.java +++ b/core/java/android/util/Patterns.java @@ -243,12 +243,12 @@ public class Patterns { public static final String GOOD_IRI_CHAR = "a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF"; - public static final Pattern IP_ADDRESS - = Pattern.compile( + private static final String IP_ADDRESS_STRING = "((25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(25[0-5]|2[0-4]" + "[0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]" + "[0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}" - + "|[1-9][0-9]|[0-9]))"); + + "|[1-9][0-9]|[0-9]))"; + public static final Pattern IP_ADDRESS = Pattern.compile(IP_ADDRESS_STRING); /** * Valid UCS characters defined in RFC 3987. Excludes space characters. @@ -298,8 +298,8 @@ public class Patterns { private static final String HOST_NAME = "(" + IRI_LABEL + "\\.)+" + TLD; - public static final Pattern DOMAIN_NAME - = Pattern.compile("(" + HOST_NAME + "|" + IP_ADDRESS + ")"); + private static final String DOMAIN_NAME_STR = "(" + HOST_NAME + "|" + IP_ADDRESS_STRING + ")"; + public static final Pattern DOMAIN_NAME = Pattern.compile(DOMAIN_NAME_STR); private static final String PROTOCOL = "(?i:http|https|rtsp):\\/\\/"; @@ -323,7 +323,7 @@ public class Patterns { public static final Pattern WEB_URL = Pattern.compile("(" + "(" + "(?:" + PROTOCOL + "(?:" + USER_INFO + ")?" + ")?" - + "(?:" + DOMAIN_NAME + ")" + + "(?:" + DOMAIN_NAME_STR + ")" + "(?:" + PORT_NUMBER + ")?" + ")" + "(" + PATH_AND_QUERY + ")?" @@ -346,14 +346,14 @@ public class Patterns { * Regular expression that matches domain names using either {@link #STRICT_HOST_NAME} or * {@link #IP_ADDRESS} */ - private static final Pattern STRICT_DOMAIN_NAME - = Pattern.compile("(?:" + STRICT_HOST_NAME + "|" + IP_ADDRESS + ")"); + private static final String STRICT_DOMAIN_NAME = "(?:" + STRICT_HOST_NAME + "|" + + IP_ADDRESS_STRING + ")"; /** * Regular expression that matches domain names without a TLD */ private static final String RELAXED_DOMAIN_NAME = - "(?:" + "(?:" + IRI_LABEL + "(?:\\.(?=\\S))" +"?)+" + "|" + IP_ADDRESS + ")"; + "(?:" + "(?:" + IRI_LABEL + "(?:\\.(?=\\S))" +"?)+" + "|" + IP_ADDRESS_STRING + ")"; /** * Regular expression to match strings that do not start with a supported protocol. The TLDs |