aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/pdf
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2009-11-06 12:25:50 +0000
committerJeremias Maerki <jeremias@apache.org>2009-11-06 12:25:50 +0000
commit96db64d94eee9593877368789a350580ea4ef92f (patch)
tree0febf9cb0205ade45979247338f252ff2d40a3f2 /src/java/org/apache/fop/pdf
parenta964e7ec2638b4373ef453e341b5cea52a169877 (diff)
downloadxmlgraphics-fop-96db64d94eee9593877368789a350580ea4ef92f.tar.gz
xmlgraphics-fop-96db64d94eee9593877368789a350580ea4ef92f.zip
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
Diffstat (limited to 'src/java/org/apache/fop/pdf')
-rw-r--r--src/java/org/apache/fop/pdf/PDFDictionary.java3
-rw-r--r--src/java/org/apache/fop/pdf/PDFName.java7
2 files changed, 7 insertions, 3 deletions
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('/');