Fixed FELIX-2338 /Problem in the Configuration Render/
https://issues.apache.org/jira/browse/FELIX-2338
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@951307 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
index 908aba4..05e2189 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
@@ -475,27 +475,74 @@
{
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 < is written
- public void write( final int character )
+ public void write(final int character)
{
- if ( doFilter && character == '<' )
+ if (doFilter)
{
- super.write( "<" );
+ 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 @@
{
if ( doFilter )
{
- writeFiltered( new String( chars, off, len ) );
+ for (int i = off; i < len; i++)
+ {
+ this.write(chars[i]);
+ }
}
else
{
@@ -518,23 +568,9 @@
// 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 )