ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1795638 - /webservices/axiom/trunk/components/core-streams/src/main/java/org/apache/axiom/core/stream/serializer/Serializer.java
Date Fri, 19 May 2017 22:39:11 GMT
Author: veithen
Date: Fri May 19 22:39:11 2017
New Revision: 1795638

URL: http://svn.apache.org/viewvc?rev=1795638&view=rev
Log:
Fix method visibility.

Modified:
    webservices/axiom/trunk/components/core-streams/src/main/java/org/apache/axiom/core/stream/serializer/Serializer.java

Modified: webservices/axiom/trunk/components/core-streams/src/main/java/org/apache/axiom/core/stream/serializer/Serializer.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/components/core-streams/src/main/java/org/apache/axiom/core/stream/serializer/Serializer.java?rev=1795638&r1=1795637&r2=1795638&view=diff
==============================================================================
--- webservices/axiom/trunk/components/core-streams/src/main/java/org/apache/axiom/core/stream/serializer/Serializer.java
(original)
+++ webservices/axiom/trunk/components/core-streams/src/main/java/org/apache/axiom/core/stream/serializer/Serializer.java
Fri May 19 22:39:11 2017
@@ -53,6 +53,13 @@ public final class Serializer implements
 
     private Context context = Context.MIXED_CONTENT;
     private int matchedIllegalCharacters;
+
+    /**
+     * Tracks the number of consecutive square brackets so that the '>' in ']]>' can
be replaced by
+     * a character reference.
+     */
+    private int squareBrackets;
+
     private String[] elementNameStack = new String[8];
     private int depth;
     private boolean startTagOpen;
@@ -75,7 +82,7 @@ public final class Serializer implements
         outputStream = out;
     }
 
-    protected void switchContext(Context context) throws StreamException {
+    private void switchContext(Context context) throws StreamException {
         this.context = context;
         try {
             writer.setUnmappableCharacterHandler(context.getUnmappableCharacterHandler());
@@ -83,6 +90,7 @@ public final class Serializer implements
             throw new StreamException(ex);
         }
         matchedIllegalCharacters = 0;
+        squareBrackets = 0;
     }
 
     /**
@@ -398,6 +406,11 @@ public final class Serializer implements
                         case '<':
                             replacement = "&lt;";
                             break;
+                        case '>':
+                            if (context == Context.MIXED_CONTENT && squareBrackets
>= 2) {
+                                replacement = "&gt;";
+                            }
+                            break;
                         case '&':
                             replacement = "&amp;";
                             break;
@@ -427,6 +440,10 @@ public final class Serializer implements
                         writer.writeCharacterReference(ch);
                     }
                     lastDirtyCharProcessed = i;
+                } else if (ch == ']') {
+                    squareBrackets++;
+                } else {
+                    squareBrackets = 0;
                 }
             }
             



Mime
View raw message