Doc generation: fix bug in russian help 57/9957/3
Calixte DENIZET [Fri, 7 Dec 2012 14:49:49 +0000 (15:49 +0100)]
Protect the tocitem

Change-Id: Iefbcd548a97aba3d9d04d04560aa328202a9923f

scilab/modules/helptools/src/java/org/scilab/modules/helptools/HTMLDocbookTagConverter.java
scilab/modules/helptools/src/java/org/scilab/modules/helptools/JavaHelpDocbookTagConverter.java

index 18c1c3c..f56aa33 100644 (file)
@@ -165,6 +165,13 @@ public class HTMLDocbookTagConverter extends DocbookTagConverter implements Temp
     }
 
     /**
+     * Replace special chars
+     */
+    public static final String replaceEntity(final String str) {
+        return str.replaceAll("&", "&amp;").replaceAll("<", "&#0060;").replaceAll(">", "&#0062;").replaceAll("\"", "&#0034;").replaceAll("\'", "&#0039;");
+    }
+
+    /**
      * Get the type of the generation
      * @return the generation type
      */
index 09c118e..96e4a51 100644 (file)
@@ -130,7 +130,7 @@ public class JavaHelpDocbookTagConverter extends HTMLDocbookTagConverter {
                 buffer.append("<tocitem target=\"");
                 buffer.append(c.id);
                 buffer.append("\" text=\"");
-                buffer.append(tocitem.get(c.id));
+                buffer.append(replaceEntity(tocitem.get(c.id)));
                 if (c.children == null) {
                     buffer.append("\"/>\n");
                 } else {