JAL-2295 avoid quotes breaking attribute value parsing
[jalview.git] / 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("'", "'");
+        sb.append("setattr r ").append(attributeName).append(" '")
+                .append(featureValue).append("' ");
         sb.append(values.get(value).getAtomSpec());
         commands.add(sb.toString());
       }