From 96d303859b3bd045af84e7c44554eee3a9c0f8d0 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Mon, 11 Oct 2010 12:41:37 +0000 Subject: [PATCH] Bugfix for unescaped name characters which can cause trouble with PDF parsers. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1021325 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/pdf/PDFName.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/fop/pdf/PDFName.java b/src/java/org/apache/fop/pdf/PDFName.java index 8214cda76..419907429 100644 --- a/src/java/org/apache/fop/pdf/PDFName.java +++ b/src/java/org/apache/fop/pdf/PDFName.java @@ -41,6 +41,7 @@ public class PDFName extends PDFObject { this.name = escapeName(name); } + private static final String ESCAPED_NAME_CHARS = "/()<>[]"; /** * Escapes a PDF name. It adds the leading slash and escapes characters as necessary. @@ -56,7 +57,8 @@ public class PDFName extends PDFObject { } for (int i = (skipFirst ? 1 : 0), c = name.length(); i < c; i++) { char ch = name.charAt(i); - if (ch < 33 || ch > 126 || ch == 0x2F) { + + if (ch < 33 || ch > 126 || ESCAPED_NAME_CHARS.indexOf(ch) >= 0) { sb.append('#'); toHex(ch, sb); } else { -- 2.39.5