From: Simon Steiner Date: Wed, 6 Jul 2016 08:27:51 +0000 (+0000) Subject: FOP-916: URL in basic-link is scrambled by encryption X-Git-Tag: fop-2_2~59 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=02b005d2d3c7bc36801fb20831d3cdc9bab05dfc;p=xmlgraphics-fop.git 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 --- 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 + ")"; + } + } }