From: Jeremias Maerki Date: Fri, 6 Nov 2009 12:25:50 +0000 (+0000) Subject: Bugfix: need to properly escape the PDF names in a dictionary (bug triggered by my... X-Git-Tag: fop-1_0~106 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=96db64d94eee9593877368789a350580ea4ef92f;p=xmlgraphics-fop.git Bugfix: need to properly escape the PDF names in a dictionary (bug triggered by my PDF plug-in) git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@833375 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/pdf/PDFDictionary.java b/src/java/org/apache/fop/pdf/PDFDictionary.java index 3258423f4..932f2d03e 100644 --- a/src/java/org/apache/fop/pdf/PDFDictionary.java +++ b/src/java/org/apache/fop/pdf/PDFDictionary.java @@ -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); diff --git a/src/java/org/apache/fop/pdf/PDFName.java b/src/java/org/apache/fop/pdf/PDFName.java index 6dabc3ac4..19db917c8 100644 --- a/src/java/org/apache/fop/pdf/PDFName.java +++ b/src/java/org/apache/fop/pdf/PDFName.java @@ -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('/');