Skip to content

Commit

Permalink
allow ampersand in image names, fixes trakem2#24
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Posch committed Mar 17, 2018
1 parent 4a4d340 commit af9672d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,22 @@ public void disposeGUIs()
rA.getConflictManager().disposeConflictFrame();
}

/** Code a string to conform to html convention
* @param rel_path
* @return
*/
public static String htmlCode( String s) {
StringBuilder out = new StringBuilder(Math.max(16, s.length()));
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') {
out.append("&#");
out.append((int) c);
out.append(';');
} else {
out.append(c);
}
}
return out.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ as published by the Free Software Foundation (http://www.gnu.org/licenses/gpl.tx
import java.util.Set;

import de.unihalle.informatik.rhizoTrak.Project;
import de.unihalle.informatik.rhizoTrak.addon.RhizoMain;
import de.unihalle.informatik.rhizoTrak.display.graphics.AddARGBComposite;
import de.unihalle.informatik.rhizoTrak.display.graphics.ColorYCbCrComposite;
import de.unihalle.informatik.rhizoTrak.display.graphics.DifferenceARGBComposite;
Expand Down Expand Up @@ -1410,7 +1411,9 @@ public void exportXML(final StringBuilder sb_body, final String in, final XMLOpt
if (!visible) sb_body.append(in).append("visible=\"false\"\n");
// 'style' is taken care in subclasses
if (null != title && title.length() > 0) {
sb_body.append(in).append("title=\"").append(title.replaceAll("\"", "^#^")).append("\"\n"); // fix possible harm by '"' characters (backslash should be taken care of as well TODO)
// code string for html
sb_body.append(in).append("title=\"").append( RhizoMain.htmlCode( title.replaceAll("\"", "^#^"))).append("\"\n"); // fix possible harm by '"' characters (backslash should be taken care of as well TODO)
// sb_body.append(in).append("title=\"").append(title.replaceAll("\"", "^#^")).append("\"\n"); // fix possible harm by '"' characters (backslash should be taken care of as well TODO)
}

if (COMPOSITE_NORMAL != compositeMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ as published by the Free Software Foundation (http://www.gnu.org/licenses/gpl.tx
import java.util.zip.ZipOutputStream;

import de.unihalle.informatik.rhizoTrak.Project;
import de.unihalle.informatik.rhizoTrak.addon.RhizoMain;
import de.unihalle.informatik.rhizoTrak.imaging.PatchStack;
import de.unihalle.informatik.rhizoTrak.imaging.filters.FilterEditor;
import de.unihalle.informatik.rhizoTrak.imaging.filters.IFilter;
Expand Down Expand Up @@ -928,8 +929,11 @@ public void exportXML(final StringBuilder sb_body, final String indent, final XM
if (null != imp) type = imp.getType();
}


// code file path for html
sb_body.append(in).append("type=\"").append(type /*null == any ? ImagePlus.GRAY8 : type*/).append("\"\n")
.append(in).append("file_path=\"").append(rel_path).append("\"\n")
.append(in).append("file_path=\"").append( RhizoMain.htmlCode( rel_path)).append("\"\n")
// .append(in).append("file_path=\"").append(rel_path).append("\"\n")
.append(in).append("style=\"fill-opacity:").append(alpha).append(";stroke:#").append(RGB[0]).append(RGB[1]).append(RGB[2]).append(";\"\n")
.append(in).append("o_width=\"").append(o_width).append("\"\n")
.append(in).append("o_height=\"").append(o_height).append("\"\n")
Expand Down

0 comments on commit af9672d

Please sign in to comment.