felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r900192 - /felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
Date Sun, 17 Jan 2010 18:51:02 GMT
Author: fmeschbe
Date: Sun Jan 17 18:51:01 2010
New Revision: 900192

URL: http://svn.apache.org/viewvc?rev=900192&view=rev
Log:
FELIX-1957 Replace use of String.replaceAll not available in OSGi/Minimum-1.0 EE by using
a StringTokenizer to replace all occurrences of "<" in strings by "&lt;".

Modified:
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java?rev=900192&r1=900191&r2=900192&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
(original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
Sun Jan 17 18:51:01 2010
@@ -31,6 +31,7 @@
 import java.util.Properties;
 import java.util.SortedMap;
 import java.util.SortedSet;
+import java.util.StringTokenizer;
 import java.util.TreeMap;
 import java.util.TreeSet;
 import java.util.zip.ZipEntry;
@@ -515,7 +516,21 @@
         {
             if ( string.indexOf( '<' ) >= 0 )
             {
-                super.write( string.replaceAll( "<", "&lt;" ) );
+                // TODO: replace with WebConsoleUtil.escapeHtml()
+                // this "convoluted" code replaces "<" by "&lt;"
+                final StringTokenizer tokener = new StringTokenizer( string, "<", true
);
+                while ( tokener.hasMoreElements() )
+                {
+                    final String token = tokener.nextToken();
+                    if ( "<".equals( token ) )
+                    {
+                        super.write( "&lt;" );
+                    }
+                    else
+                    {
+                        super.write( token );
+                    }
+                }
             }
             else
             {



Mime
View raw message