提交 1b2adf36 编写于 作者: C coffeys

8071125: Improve exception messages in URLPermission

Reviewed-by: chegar, prappo
上级 6f00077f
...@@ -170,7 +170,8 @@ public final class URLPermission extends Permission { ...@@ -170,7 +170,8 @@ public final class URLPermission extends Permission {
parseURI(getName()); parseURI(getName());
int colon = actions.indexOf(':'); int colon = actions.indexOf(':');
if (actions.lastIndexOf(':') != colon) { if (actions.lastIndexOf(':') != colon) {
throw new IllegalArgumentException("invalid actions string"); throw new IllegalArgumentException(
"Invalid actions string: \"" + actions + "\"");
} }
String methods, headers; String methods, headers;
...@@ -371,7 +372,8 @@ public final class URLPermission extends Permission { ...@@ -371,7 +372,8 @@ public final class URLPermission extends Permission {
l.add(s); l.add(s);
b = new StringBuilder(); b = new StringBuilder();
} else if (c == ' ' || c == '\t') { } else if (c == ' ' || c == '\t') {
throw new IllegalArgumentException("white space not allowed"); throw new IllegalArgumentException(
"White space not allowed in methods: \"" + methods + "\"");
} else { } else {
if (c >= 'a' && c <= 'z') { if (c >= 'a' && c <= 'z') {
c += 'A' - 'a'; c += 'A' - 'a';
...@@ -398,7 +400,8 @@ public final class URLPermission extends Permission { ...@@ -398,7 +400,8 @@ public final class URLPermission extends Permission {
} }
b.append(c); b.append(c);
} else if (c == ' ' || c == '\t') { } else if (c == ' ' || c == '\t') {
throw new IllegalArgumentException("white space not allowed"); throw new IllegalArgumentException(
"White space not allowed in headers: \"" + headers + "\"");
} else if (c == '-') { } else if (c == '-') {
capitalizeNext = true; capitalizeNext = true;
b.append(c); b.append(c);
...@@ -423,14 +426,16 @@ public final class URLPermission extends Permission { ...@@ -423,14 +426,16 @@ public final class URLPermission extends Permission {
int len = url.length(); int len = url.length();
int delim = url.indexOf(':'); int delim = url.indexOf(':');
if (delim == -1 || delim + 1 == len) { if (delim == -1 || delim + 1 == len) {
throw new IllegalArgumentException("invalid URL string"); throw new IllegalArgumentException(
"Invalid URL string: \"" + url + "\"");
} }
scheme = url.substring(0, delim).toLowerCase(); scheme = url.substring(0, delim).toLowerCase();
this.ssp = url.substring(delim + 1); this.ssp = url.substring(delim + 1);
if (!ssp.startsWith("//")) { if (!ssp.startsWith("//")) {
if (!ssp.equals("*")) { if (!ssp.equals("*")) {
throw new IllegalArgumentException("invalid URL string"); throw new IllegalArgumentException(
"Invalid URL string: \"" + url + "\"");
} }
this.authority = new Authority(scheme, "*"); this.authority = new Authority(scheme, "*");
return; return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册