felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vvalc...@apache.org
Subject svn commit: r951307 - /felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
Date Fri, 04 Jun 2010 07:22:18 GMT
Author: vvalchev
Date: Fri Jun  4 07:22:18 2010
New Revision: 951307

URL: http://svn.apache.org/viewvc?rev=951307&view=rev
Log:
Fixed FELIX-2338 /Problem in the Configuration Render/
https://issues.apache.org/jira/browse/FELIX-2338

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=951307&r1=951306&r2=951307&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
Fri Jun  4 07:22:18 2010
@@ -475,27 +475,74 @@ public class ConfigurationRender extends
         {
             if ( doFilter )
             {
-                super.write( "<br/>", 0, 5 );
+                oldch = '_';
+                this.write('\n'); // write <br/>
             }
             else
             {
                 super.println();
             }
+            oldch = '\n';
         }
 
+        private int oldch = '_';
 
         // write the character unmodified unless filtering is enabled and
         // the character is a "<" in which case &lt; is written
-        public void write( final int character )
+        public void write(final int character)
         {
-            if ( doFilter && character == '<' )
+            if (doFilter)
             {
-                super.write( "&lt;" );
+                switch (character)
+                {
+                    case '<':
+                        super.write('&');
+                        super.write('l');
+                        super.write('t');
+                        super.write(';');
+                        break;
+                    case '>':
+                        super.write('&');
+                        super.write('g');
+                        super.write('t');
+                        super.write(';');
+                        break;
+                    case '&':
+                        super.write('&');
+                        super.write('a');
+                        super.write('m');
+                        super.write('p');
+                        super.write(';');
+                        break;
+                    case ' ':
+                        super.write('&');
+                        super.write('n');
+                        super.write('b');
+                        super.write('s');
+                        super.write('p');
+                        super.write(';');
+                        break;
+                    case '\r':
+                    case '\n':
+                        if (oldch != '\r' && oldch != '\n')
+                        {// don't add twice <br>
+                            super.write('<');
+                            super.write('b');
+                            super.write('r');
+                            super.write('/');
+                            super.write('>');
+                            super.write('\n');
+                        }
+                        break;
+                    default:
+                        super.write(character);
+                }
             }
             else
             {
-                super.write( character );
+                super.write(character);
             }
+            oldch = character;
         }
 
 
@@ -505,7 +552,10 @@ public class ConfigurationRender extends
         {
             if ( doFilter )
             {
-                writeFiltered( new String( chars, off, len ) );
+                for (int i = off; i < len; i++)
+                {
+                    this.write(chars[i]);
+                }
             }
             else
             {
@@ -518,23 +568,9 @@ public class ConfigurationRender extends
         // which case the writeFiltered(String) method is called for filtering
         public void write( final String string, final int off, final int len )
         {
-            if ( doFilter )
-            {
-                writeFiltered( string.substring( off, len ) );
-            }
-            else
-            {
-                super.write( string, off, len );
-            }
+            write(string.toCharArray(), off, len);
         }
 
-
-        // helper method filter the string for "<" before writing
-        private void writeFiltered( String string )
-        {
-            string = WebConsoleUtil.escapeHtml(string); // filtering
-            super.write( string, 0, string.length() );
-        }
     }
 
     private void addAttachments( final ConfigurationWriter cf, final String mode )



Mime
View raw message