JAL-2295 avoid quotes breaking attribute value parsing
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 8 Mar 2017 11:15:27 +0000 (11:15 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 8 Mar 2017 11:15:27 +0000 (11:15 +0000)
src/jalview/ext/rbvi/chimera/ChimeraCommands.java

index c4aa2e7..bb9df8a 100644 (file)
@@ -473,10 +473,13 @@ public class ChimeraCommands
         /*
          * for each distinct value recorded for this feature type,
          * add a command to set the attribute on the mapped residues
+         * Put values in single quotes, encoding any embedded single quotes
          */
         StringBuilder sb = new StringBuilder(128);
-        sb.append("setattr r ").append(attributeName).append(" \"")
-                .append(value.toString()).append("\" ");
+        String featureValue = value.toString();
+        featureValue.replaceAll("'", "&#39;");
+        sb.append("setattr r ").append(attributeName).append(" '")
+                .append(featureValue).append("' ");
         sb.append(values.get(value).getAtomSpec());
         commands.add(sb.toString());
       }