Skip to content

Commit 6ad1c0d

Browse files
authored
Merge pull request #260 from Handig-Eekhoorn/fix-font-family-escape
FontFamily.convertString() double-escapes already escaped strings
2 parents e7b5ee9 + 4214b0a commit 6ad1c0d

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

org/w3c/css/properties/css2/font/FontFamily.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,23 @@ public String toString() {
143143
}
144144

145145
String convertString(String value) {
146-
if (value.indexOf('"') != -1) {
147-
return '\'' + value + '\'';
148-
} else if (value.indexOf('\'') != -1) {
149-
return '"' + value + '"';
150-
} else {
151-
return value;
152-
}
146+
char cfirst = value.charAt(0);
147+
char clast = value.charAt(value.length()-1);
148+
149+
if (cfirst == clast
150+
&& (cfirst == '\'' || cfirst=='"')
151+
){
152+
// is already well escaped
153+
return value;
154+
}
155+
156+
if (value.indexOf('"') != -1) {
157+
return '\'' + value + '\'';
158+
} else if (value.indexOf('\'') != -1) {
159+
return '"' + value + '"';
160+
} else {
161+
return value;
162+
}
153163
}
154164

155165
/**

0 commit comments

Comments
 (0)