Author: Alex.Kolonitsky
Date: 2009-03-12 11:14:52 -0400 (Thu, 12 Mar 2009)
New Revision: 12935
Modified:
trunk/ui/editor/src/main/antlr/html-seamtext.g
trunk/ui/editor/src/test/java/org/richfaces/seamparser/HtmlSeamParserTest.java
Log:
editor: special characters escapement problem
https://jira.jboss.org/jira/browse/RF-5717
Modified: trunk/ui/editor/src/main/antlr/html-seamtext.g
===================================================================
--- trunk/ui/editor/src/main/antlr/html-seamtext.g 2009-03-12 14:15:48 UTC (rev 12934)
+++ trunk/ui/editor/src/main/antlr/html-seamtext.g 2009-03-12 15:14:52 UTC (rev 12935)
@@ -377,7 +377,7 @@
if ("<".equals(tokenName)) {
result.append("\\<");
} else if("&".equals(tokenName)) {
- result.append("&");
+ result.append("\\&");
} else if (">".equals(tokenName)) {
result.append("\\>");
} else if(""".equals(tokenName)){
@@ -435,10 +435,7 @@
)*)+
;
-plain: (word|punctuation|space:SPACE {
- append(space.getText());}
- )
-
+plain: (word|punctuation|space:SPACE {append(space.getText());} )
{
Token token = LT(2);
if(!isParagraph(token) && isHeaderProcessed) {
Modified: trunk/ui/editor/src/test/java/org/richfaces/seamparser/HtmlSeamParserTest.java
===================================================================
---
trunk/ui/editor/src/test/java/org/richfaces/seamparser/HtmlSeamParserTest.java 2009-03-12
14:15:48 UTC (rev 12934)
+++
trunk/ui/editor/src/test/java/org/richfaces/seamparser/HtmlSeamParserTest.java 2009-03-12
15:14:52 UTC (rev 12935)
@@ -123,7 +123,6 @@
private final static String SEAM_TEXT_EXPRESSION_29 = "A, B, C, D, E, F, G, H, I,
J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9";
private final static String SEAM_TEXT_EXPRESSION_30 = "<div/>";
-
@@ -251,6 +250,10 @@
assertSeamConverting(SEAM_TEXT_EXPRESSION_30);
}
+ public void testRF5717() throws Exception {
+ assertHtml2SeamConverting("<p>a&b</p>",
"a&b");
+ }
+
@@ -260,20 +263,41 @@
/**
* Method to assert converting from Seam Text to html and back
- * @param seamTextExpression
+ * @param htmlText
* @throws Exception
*/
- private void assertSeamConverting(String seamTextExpression)
+ private void assertHtml2SeamConverting(String htmlText, String resultContain)
throws Exception {
- SeamTextParser seamParser = new SeamTextParser(new SeamTextLexer(new
StringReader(seamTextExpression)));
+ HtmlSeamTextParser htmlParser = new HtmlSeamTextParser(
+ new HtmlSeamTextLexer(new StringReader(htmlText)));
+ htmlParser.startRule();
+ String seamText = htmlParser.toString();
+
+ SeamTextParser seamParser = new SeamTextParser(
+ new SeamTextLexer(new StringReader(seamText)));
seamParser.startRule();
String html = seamParser.toString();
-
- HtmlSeamTextParser htmlParser = new HtmlSeamTextParser(new HtmlSeamTextLexer(new
StringReader(html)));
- htmlParser.startRule();
- String seamtext = htmlParser.toString();
- assertEquals(seamTextExpression,seamtext.trim());
+ assertTrue(html.contains(resultContain));
}
+
+ /**
+ * Method to assert converting from Seam Text to html and back
+ * @param seamTextExpression
+ * @throws Exception
+ */
+ private void assertSeamConverting(String seamTextExpression)
+ throws Exception {
+
+ SeamTextParser seamParser = new SeamTextParser(new SeamTextLexer(new
StringReader(seamTextExpression)));
+ seamParser.startRule();
+ String html = seamParser.toString();
+
+ HtmlSeamTextParser htmlParser = new HtmlSeamTextParser(new HtmlSeamTextLexer(new
StringReader(html)));
+ htmlParser.startRule();
+ String seamtext = htmlParser.toString();
+
+ assertEquals(seamTextExpression,seamtext.trim());
+ }
}