]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugfix: need to properly escape the PDF names in a dictionary (bug triggered by my...
authorJeremias Maerki <jeremias@apache.org>
Fri, 6 Nov 2009 12:25:50 +0000 (12:25 +0000)
committerJeremias Maerki <jeremias@apache.org>
Fri, 6 Nov 2009 12:25:50 +0000 (12:25 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@833375 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/pdf/PDFDictionary.java
src/java/org/apache/fop/pdf/PDFName.java

index 3258423f4e3f4d0b232b1f6a7c4806000340bf36..932f2d03e5ac93b6a91435b47e19369e0ffb6ebe 100644 (file)
@@ -133,8 +133,7 @@ public class PDFDictionary extends PDFObject {
             } else {
                 writer.write("\n  ");
             }
-            writer.write('/');
-            writer.write(key);
+            writer.write(PDFName.escapeName(key));
             writer.write(' ');
             Object obj = this.entries.get(key);
             formatObject(obj, out, writer);
index 6dabc3ac47d2688afad610bee107a71d8b95d40d..19db917c8c87b9c9f4c314b7c8eedb22bd1e8825 100644 (file)
@@ -42,7 +42,12 @@ public class PDFName extends PDFObject {
     }
 
 
-    private static String escapeName(String name) {
+    /**
+     * Escapes a PDF name. It adds the leading slash and escapes characters as necessary.
+     * @param name the name
+     * @return the escaped name
+     */
+    static String escapeName(String name) {
         StringBuffer sb = new StringBuffer(Math.min(16, name.length() + 4));
         if (!name.startsWith("/")) {
             sb.append('/');