From 02b005d2d3c7bc36801fb20831d3cdc9bab05dfc Mon Sep 17 00:00:00 2001 From: Simon Steiner Date: Wed, 6 Jul 2016 08:27:51 +0000 Subject: [PATCH] FOP-916: URL in basic-link is scrambled by encryption git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1751621 13f79535-47bb-0310-9956-ffa450edef68 --- fop-core/src/main/java/org/apache/fop/pdf/PDFUri.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFUri.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFUri.java index a42b9c872..bc17dd997 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFUri.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFUri.java @@ -49,7 +49,7 @@ public class PDFUri extends PDFAction { } private String getDictString() { - return "<< /URI (" + encodeString(uri) + ")\n/S /URI >>"; + return "<< /URI " + encodeURI(uri) + "\n/S /URI >>"; } /** {@inheritDoc} */ @@ -58,4 +58,13 @@ public class PDFUri extends PDFAction { return getDictString(); } + private String encodeURI(String text) { + if (getDocument() != null && getDocumentSafely().isEncryptionActive()) { + final byte[] buf = PDFText.encode(text); + byte[] enc = getDocument().getEncryption().encrypt(buf, this); + return PDFText.toHex(enc, true); + } else { + return "(" + text + ")"; + } + } } -- 2.39.5