Author: tilman
Date: Sun Sep 17 09:30:46 2017
New Revision: 1808608

URL: http://svn.apache.org/viewvc?rev=1808608&view=rev
Log:
PDFBOX-3913: support utf8 URIs

Added:
    
pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/interactive/
    
pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/interactive/PDActionURITest.java
   (with props)
Modified:
    
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionURI.java

Modified: 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionURI.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionURI.java?rev=1808608&r1=1808607&r2=1808608&view=diff
==============================================================================
--- 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionURI.java
 (original)
+++ 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/action/PDActionURI.java
 Sun Sep 17 09:30:46 2017
@@ -18,6 +18,8 @@ package org.apache.pdfbox.pdmodel.intera
 
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.cos.COSString;
+import org.apache.pdfbox.util.Charsets;
 
 /**
  * This represents a URI action that can be executed in a PDF document.
@@ -78,14 +80,14 @@ public class PDActionURI extends PDActio
     }
 
     /**
-     * This will get the uniform resource identifier to resolve, encoded in
-     * 7-bit ASCII.
+     * This will get the uniform resource identifier to resolve. It should be 
encoded in 7-bit
+     * ASCII, but UTF-8 is supported too.
      *
      * @return The URI entry of the specific URI action dictionary.
      */
     public String getURI()
     {
-        return action.getString(COSName.URI);
+        return new String(((COSString) 
action.getDictionaryObject(COSName.URI)).getBytes(), Charsets.UTF_8);
     }
 
     /**

Added: 
pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/interactive/PDActionURITest.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/interactive/PDActionURITest.java?rev=1808608&view=auto
==============================================================================
--- 
pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/interactive/PDActionURITest.java
 (added)
+++ 
pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/interactive/PDActionURITest.java
 Sun Sep 17 09:30:46 2017
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2017 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdmodel.interactive.action;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+/**
+ *
+ * @author Tilman Hausherr
+ */
+public class PDActionURITest
+{
+    /**
+     * PDFBOX-3913: Check that URIs encoded in UTF-8 are also supported.
+     */
+    @Test
+    public void testUTF8URI()
+    {
+        PDActionURI actionURI = new PDActionURI();
+        actionURI.setURI("http://組匶替綎.com/";);
+        assertEquals("http://経営承継.com/";, actionURI.getURI());
+    }
+}

Propchange: 
pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/interactive/PDActionURITest.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to