JAL-2543 html-encode quote characters in feature description
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 18 May 2017 14:28:54 +0000 (15:28 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 18 May 2017 14:28:54 +0000 (15:28 +0100)
src/jalview/gui/AlignmentPanel.java

index 885d79d..0c052d9 100644 (file)
@@ -1556,35 +1556,37 @@ public class AlignmentPanel extends GAlignmentPanel implements
               for (f = 0; f < fSize; f++)
               {
 
-                if ((features[f].getBegin() <= seq.findPosition(res))
-                        && (features[f].getEnd() >= seq.findPosition(res)))
+                SequenceFeature sf = features[f];
+                if ((sf.getBegin() <= seq.findPosition(res))
+                        && (sf.getEnd() >= seq.findPosition(res)))
                 {
-                  if (features[f].isContactFeature())
+                  if (sf.isContactFeature())
                   {
-                    if (features[f].getBegin() == seq.findPosition(res)
-                            || features[f].getEnd() == seq
+                    if (sf.getBegin() == seq.findPosition(res)
+                            || sf.getEnd() == seq
                                     .findPosition(res))
                     {
-                      text.append("<br>").append(features[f].getType())
-                              .append(" ").append(features[f].getBegin())
-                              .append(":").append(features[f].getEnd());
+                      text.append("<br>").append(sf.getType())
+                              .append(" ").append(sf.getBegin())
+                              .append(":").append(sf.getEnd());
                     }
                   }
                   else
                   {
                     text.append("<br>");
-                    text.append(features[f].getType());
-                    if (features[f].getDescription() != null
-                            && !features[f].getType().equals(
-                                    features[f].getDescription()))
+                    text.append(sf.getType());
+                    String description = sf.getDescription();
+                    if (description != null
+                            && !sf.getType().equals(description))
                     {
-                      text.append(" ").append(features[f].getDescription());
+                      description = description.replace("\"", "&quot;");
+                      text.append(" ").append(description);
                     }
 
-                    if (features[f].getValue("status") != null)
+                    String status = sf.getStatus();
+                    if (status != null && !"".equals(status))
                     {
-                      text.append(" (").append(features[f].getValue("status"))
-                              .append(")");
+                      text.append(" (").append(status).append(")");
                     }
                   }
                 }