Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

revise the "escaped" characters in XML/XHTML.

Use   instead of   since it's also valid in xml.
  • Loading branch information...
commit 784ba93b510f7e2956782b0b2f4068782d5d1f4a 1 parent a3d9b40
@lhotari lhotari authored
View
19 ...s-plugin-codecs/src/main/groovy/org/codehaus/groovy/grails/plugins/codecs/XMLEncoder.java
@@ -6,15 +6,18 @@
public class XMLEncoder extends AbstractCharReplacementEncoder {
static final String XML_CODEC_NAME="EscapedXML";
- private static final String ESCAPED_BACKTICK = "&#" + ((int) '`') + ";";
- private static final String ESCAPED_AT = "&#" + ((int) '@') + ";";
- private static final String ESCAPED_EQUAL = "&#" + ((int) '=') + ";";
- private static final String ESCAPED_PLUS = "&#" + ((int) '+') + ";";
- private static final String ESCAPED_APOS = "&#" + ((int) '\'') + ";";
+ private static final String ESCAPED_APOS = "&#" + ((int) '\'') + ";"; // html doesn't have apos, so use numeric entity
private static final String ESCAPED_QUOTE = """;
private static final String ESCAPED_GT = ">";
private static final String ESCAPED_LT = "<";
private static final String ESCAPED_AMP = "&";
+ // some extras
+ private static final String ESCAPED_BACKSLASH = "&#" + ((int) '\\') + ";";
+ private static final char NBSP=(char)160;
+ private static final String ESCAPED_NON_BREAKING_SPACE = "&#" + ((int) NBSP) + ";";
+ private static final String ESCAPED_BACKTICK = "&#" + ((int) '`') + ";";
+ private static final String ESCAPED_AT = "&#" + ((int) '@') + ";"; // IE Javascript conditional compilation rules
+
private static final Set<String> equivalentCodecNames = new HashSet<String>(Arrays.asList(new String[]{"HTML4",HTMLCodec.CODEC_NAME}));
@Override
@@ -28,10 +31,10 @@ protected String escapeCharacter(char ch) {
case '>': return ESCAPED_GT;
case '"': return ESCAPED_QUOTE;
case '\'': return ESCAPED_APOS;
- case '+': return ESCAPED_PLUS;
- case '=': return ESCAPED_EQUAL;
- case '@': return ESCAPED_AT;
+ case '\\': return ESCAPED_BACKSLASH;
+ case '@': return ESCAPED_AT;
case '`': return ESCAPED_BACKTICK;
+ case NBSP: return ESCAPED_NON_BREAKING_SPACE;
}
return null;
}
View
2  ...te-web/src/test/groovy/org/codehaus/groovy/grails/web/taglib/ValidationTagLibTests.groovy
@@ -215,7 +215,7 @@ enum Title implements org.springframework.context.MessageSourceResolvable {
// And then with French.
webRequest.currentRequest.addPreferredLocale(Locale.FRENCH)
- assertOutputEquals '<input type="text" name="usPrice" value="1&nbsp;045,99" id="usPrice" />',
+ assertOutputEquals '<input type="text" name="usPrice" value="1&#160;045,99" id="usPrice" />',
template, [book:b]
}
Please sign in to comment.
Something went wrong with that request. Please try again.