You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2012/05/16 11:05:00 UTC
svn commit: r1339070 - in /myfaces/tobago/trunk:
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/
tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/
tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobag...
Author: lofwyr
Date: Wed May 16 09:05:00 2012
New Revision: 1339070
URL: http://svn.apache.org/viewvc?rev=1339070&view=rev
Log:
TOBAGO-1133: Filter control characters, so they don't be send to the user agent
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/HtmlWriterUtils.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TextareaRenderer.java
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/HtmlWriterUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/HtmlWriterUtils.java?rev=1339070&r1=1339069&r2=1339070&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/HtmlWriterUtils.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/HtmlWriterUtils.java Wed May 16 09:05:00 2012
@@ -20,11 +20,6 @@ package org.apache.myfaces.tobago.intern
import java.io.IOException;
import java.io.Writer;
-/**
- * User: weber
- * Date: Jun 28, 2005
- * Time: 2:07:29 PM
- */
public final class HtmlWriterUtils {
private static final char[][] CHARS_TO_ESCAPE;
@@ -32,13 +27,28 @@ public final class HtmlWriterUtils {
static {
// init lookup table
CHARS_TO_ESCAPE = new char[0xA0][];
+
+ final char[] EMPTY = "".toCharArray();
+ for (int i = 0; i < 0x20; i++) {
+ CHARS_TO_ESCAPE[i] = EMPTY; // Control characters
+ }
+
+ CHARS_TO_ESCAPE['\t'] = "	".toCharArray(); // Horizontal tabulator
+ CHARS_TO_ESCAPE['\n'] = " ".toCharArray(); // Line feed
+ CHARS_TO_ESCAPE['\r'] = " ".toCharArray(); // Carriage return
+
CHARS_TO_ESCAPE['"'] = """.toCharArray();
CHARS_TO_ESCAPE['&'] = "&".toCharArray();
CHARS_TO_ESCAPE['<'] = "<".toCharArray();
CHARS_TO_ESCAPE['>'] = ">".toCharArray();
- CHARS_TO_ESCAPE['\n'] = " ".toCharArray();
- CHARS_TO_ESCAPE['\r'] = " ".toCharArray();
- CHARS_TO_ESCAPE['\t'] = "	".toCharArray();
+
+ CHARS_TO_ESCAPE[0x7F] = EMPTY; // Delete
+
+ for (int i = 0x80; i < 0xA0; i++) {
+ CHARS_TO_ESCAPE[i] = EMPTY; // Control characters
+ }
+
+ // all "normal" character positions contains null
}
private final Writer out;
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java?rev=1339070&r1=1339069&r2=1339070&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java Wed May 16 09:05:00 2012
@@ -97,7 +97,10 @@ public class TobagoResponseWriterUnitTes
public void testManyChars() throws IOException {
writer.startElement(HtmlElements.SELECT, null);
StringBuffer buffer = new StringBuffer();
- for (char c = 0x20; c < 0x1ff; c++) {
+ for (char c = 0x20; c < 0x7F; c++) {
+ buffer.append(c);
+ }
+ for (char c = 0xA0; c < 0x1ff; c++) {
buffer.append(c);
}
writer.writeAttribute(HtmlAttributes.VALUE, buffer, null);
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TextareaRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TextareaRenderer.java?rev=1339070&r1=1339069&r2=1339070&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TextareaRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TextareaRenderer.java Wed May 16 09:05:00 2012
@@ -101,7 +101,7 @@ public class TextareaRenderer extends In
} else if (currentValue.startsWith("\r")) {
currentValue = "\r" + currentValue;
}
- writer.writeText(currentValue, null);
+ writer.writeText(currentValue);
}
writer.endElement(HtmlElements.TEXTAREA);
/*if (placeholder != null && !VariableResolverUtils.resolveClientProperties(facesContext)