chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1597611 - in /chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench: ./ swing/
Date Mon, 26 May 2014 16:09:19 GMT
Author: fmui
Date: Mon May 26 16:09:18 2014
New Revision: 1597611

URL: http://svn.apache.org/r1597611
Log:
Workbench: encode HTML values

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/PropertyEditorFrame.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/QueryFrame.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CollectionRenderer.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/IdRenderer.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java?rev=1597611&r1=1597610&r2=1597611&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
Mon May 26 16:09:18 2014
@@ -418,6 +418,27 @@ public final class ClientHelper {
         clipboard.setContents(transferable, null);
     }
 
+    public static String encodeHtml(StringBuilder sb, String s) {
+        for (int i = 0; i < s.length(); i++) {
+            char c = s.charAt(i);
+            if (c == '<') {
+                sb.append("&lt;");
+            } else if (c == '<') {
+                sb.append("&lt;");
+            } else if (c == '"') {
+                sb.append("&quot;");
+            } else if (c == '\'') {
+                sb.append("&apos;");
+            } else if (c > 127) {
+                sb.append("&#" + (int) c + ";");
+            } else {
+                sb.append(c);
+            }
+        }
+
+        return sb.toString();
+    }
+
     private static String formatCSVValue(Object value) {
         if (value == null) {
             return "";

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/PropertyEditorFrame.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/PropertyEditorFrame.java?rev=1597611&r1=1597610&r2=1597611&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/PropertyEditorFrame.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/PropertyEditorFrame.java
Mon May 26 16:09:18 2014
@@ -273,9 +273,13 @@ public class PropertyEditorFrame extends
             JPanel titlePanel = new JPanel();
             titlePanel.setLayout(new BorderLayout());
             titlePanel.setBackground(bgColor);
-            titlePanel.setToolTipText("<html><b>" + propDef.getPropertyType().value()
+ "</b> ("
-                    + propDef.getCardinality().value() + " value)"
-                    + (propDef.getDescription() != null ? "<br>" + propDef.getDescription()
: ""));
+            titlePanel.setToolTipText("<html><b>"
+                    + propDef.getPropertyType().value()
+                    + "</b> ("
+                    + propDef.getCardinality().value()
+                    + " value)"
+                    + (propDef.getDescription() != null ? "<br>"
+                            + ClientHelper.encodeHtml(new StringBuilder(), propDef.getDescription())
: ""));
             add(titlePanel);
 
             JPanel namePanel = new JPanel();

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/QueryFrame.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/QueryFrame.java?rev=1597611&r1=1597610&r2=1597611&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/QueryFrame.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/QueryFrame.java
Mon May 26 16:09:18 2014
@@ -453,7 +453,11 @@ public class QueryFrame extends JFrame {
                     } else {
                         sb.append("<br>");
                     }
-                    sb.append(value.toString());
+                    if (value == null) {
+                        sb.append("<i>null</i>");
+                    } else {
+                        ClientHelper.encodeHtml(sb, value.toString());
+                    }
                 }
 
                 result = sb.toString();

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CollectionRenderer.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CollectionRenderer.java?rev=1597611&r1=1597610&r2=1597611&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CollectionRenderer.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/CollectionRenderer.java
Mon May 26 16:09:18 2014
@@ -82,9 +82,16 @@ public class CollectionRenderer extends 
             } else if (o instanceof GregorianCalendar) {
                 sb.append(ClientHelper.getDateString((GregorianCalendar) o));
             } else if (o instanceof Choice<?>) {
-                sb.append(((Choice<?>) o).getValue());
+                Object choiceValue = ((Choice<?>) o).getValue();
+                if (choiceValue == null) {
+                    sb.append("<i>null</i>");
+                } else if (o instanceof GregorianCalendar) {
+                    sb.append(ClientHelper.getDateString((GregorianCalendar) o));
+                } else {
+                    ClientHelper.encodeHtml(sb, choiceValue.toString());
+                }
             } else {
-                sb.append(o.toString());
+                ClientHelper.encodeHtml(sb, o.toString());
             }
             sb.append("</span><br/>");
         }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/IdRenderer.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/IdRenderer.java?rev=1597611&r1=1597610&r2=1597611&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/IdRenderer.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/IdRenderer.java
Mon May 26 16:09:18 2014
@@ -46,7 +46,10 @@ public class IdRenderer extends DefaultT
         String text = "";
         if (value instanceof ObjectId) {
             if (((ObjectId) value).getId() != null) {
-                text = "<html><u>" + ((ObjectId) value).getId() + "</u></html>";
+                StringBuilder sb = new StringBuilder("<html><u>");
+                ClientHelper.encodeHtml(sb, ((ObjectId) value).getId());
+                sb.append("</u></html>");
+                text = sb.toString();
             }
         }
 



Mime
View raw message