@@ -57,6 +57,7 @@ public final int getType() {
57
57
58
58
String value ;
59
59
String full = null ;
60
+ private boolean addQuotes = false ;
60
61
61
62
URL base ;
62
63
URL urlValue = null ;
@@ -89,17 +90,22 @@ public void set(String s, ApplContext ac, URL base)
89
90
this .base = base ;
90
91
91
92
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
+ }
101
107
}
102
-
108
+
103
109
value = filterURLData (urlname );
104
110
full = null ;
105
111
if (!urlHeading .startsWith ("url" ))
@@ -165,7 +171,11 @@ public String toString() {
165
171
return full ;
166
172
}
167
173
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
+ }
169
179
return full = sb .toString ();
170
180
}
171
181
0 commit comments