Author: sergeyhalipov
Date: 2008-01-10 07:33:37 -0500 (Thu, 10 Jan 2008)
New Revision: 5259
Modified:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DragSupportRenderer.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DropSupportRenderer.java
Log:
http://jira.jboss.com/jira/browse/RF-1678
Modified:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java 2008-01-10
12:26:23 UTC (rev 5258)
+++
trunk/framework/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java 2008-01-10
12:33:37 UTC (rev 5259)
@@ -27,10 +27,13 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import org.ajax4jsf.org.w3c.tidy.EntityTable;
import org.ajax4jsf.renderkit.AjaxChildrenRenderer;
import org.ajax4jsf.resource.InternetResource;
@@ -236,4 +239,21 @@
encoder.doEncode(context, component);
}
}
+
+ protected String escapeHtmlEntities(CharSequence orig) {
+ StringBuffer buff = new StringBuffer(orig);
+ EntityTable defaultEntityTable = EntityTable.getDefaultEntityTable();
+ Matcher matcher = Pattern.compile("\\&\\w+\\;").matcher(orig);
+ int delta = 0;
+ while (matcher.find()) {
+ String name = matcher.group().substring(0, matcher.group().length() - 1);
+ int code = defaultEntityTable.entityCode(name);
+ if (0 != code) {
+ String replacement = "&#" + code + ";";
+ buff.replace(matcher.start() - delta, matcher.end() - delta, replacement);
+ delta = delta + matcher.group().length() - replacement.length();
+ }
+ }
+ return buff.toString();
+ }
}
Modified:
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DragSupportRenderer.java
===================================================================
---
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DragSupportRenderer.java 2008-01-10
12:26:23 UTC (rev 5258)
+++
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DragSupportRenderer.java 2008-01-10
12:33:37 UTC (rev 5259)
@@ -106,7 +106,7 @@
writer.startElement(HTML.SCRIPT_ELEM, component);
writer.writeAttribute("id", component.getClientId(context), "id");
- writer.write(buffer.toString());
+ writer.write(escapeHtmlEntities(buffer));
writer.endElement(HTML.SCRIPT_ELEM);
}
}
Modified:
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DropSupportRenderer.java
===================================================================
---
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DropSupportRenderer.java 2008-01-10
12:26:23 UTC (rev 5258)
+++
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DropSupportRenderer.java 2008-01-10
12:33:37 UTC (rev 5259)
@@ -107,7 +107,7 @@
writer.startElement(HTML.SCRIPT_ELEM, component);
writer.writeAttribute("id", component.getClientId(context), "id");
- writer.write(buffer.toString());
+ writer.write(escapeHtmlEntities(buffer));
writer.endElement(HTML.SCRIPT_ELEM);
}
}