Skip to content

Commit b89537e

Browse files
committed
add back quotes if they were removed following w3c#259
1 parent abeca29 commit b89537e

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

org/w3c/css/values/CssURL.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public final int getType() {
5757

5858
String value;
5959
String full = null;
60+
private boolean addQuotes = false;
6061

6162
URL base;
6263
URL urlValue = null;
@@ -89,17 +90,22 @@ public void set(String s, ApplContext ac, URL base)
8990
this.base = base;
9091

9192
urlname = urlname.trim();
92-
if (urlname.isEmpty()){
93-
// okay, no further modifications needed
94-
}else if (urlname.charAt(0)=='"' || urlname.charAt(0)=='\''){
95-
final int l = urlname.length()-1;
96-
if (urlname.charAt(0)==urlname.charAt(l)){
97-
urlname = urlname.substring(1, l);
98-
}else{
99-
throw new InvalidParamException("url", s, ac);
100-
}
93+
if (urlname.isEmpty()) {
94+
// okay, no further modifications needed
95+
} else {
96+
char firstc = urlname.charAt(0);
97+
98+
if (firstc == '"' || firstc == '\'') {
99+
final int l = urlname.length() - 1;
100+
if (firstc == urlname.charAt(l)) {
101+
urlname = urlname.substring(1, l);
102+
addQuotes = true;
103+
} else {
104+
throw new InvalidParamException("url", s, ac);
105+
}
106+
}
101107
}
102-
108+
103109
value = filterURLData(urlname);
104110
full = null;
105111
if (!urlHeading.startsWith("url"))
@@ -165,7 +171,11 @@ public String toString() {
165171
return full;
166172
}
167173
StringBuilder sb = new StringBuilder("url(");
168-
sb.append(value).append(')');
174+
if (addQuotes) {
175+
sb.append('"').append(value).append("\")");
176+
} else {
177+
sb.append(value).append(')');
178+
}
169179
return full = sb.toString();
170180
}
171181

0 commit comments

Comments
 (0)