pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1763300 - in /pdfbox/branches/2.0: fontbox/src/main/java/org/apache/fontbox/util/autodetect/WindowsFontDirFinder.java pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java
Date Tue, 04 Oct 2016 16:53:13 GMT
Author: tilman
Date: Tue Oct  4 16:53:13 2016
New Revision: 1763300

URL: http://svn.apache.org/viewvc?rev=1763300&view=rev
Log:
PDFBOX-3520: more resiliency against security manager fails

Modified:
    pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/util/autodetect/WindowsFontDirFinder.java
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java

Modified: pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/util/autodetect/WindowsFontDirFinder.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/util/autodetect/WindowsFontDirFinder.java?rev=1763300&r1=1763299&r2=1763300&view=diff
==============================================================================
--- pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/util/autodetect/WindowsFontDirFinder.java
(original)
+++ pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/util/autodetect/WindowsFontDirFinder.java
Tue Oct  4 16:53:13 2016
@@ -82,6 +82,10 @@ public class WindowsFontDirFinder implem
             {
                 // should continue if this fails
             }
+            catch (SecurityException e)
+            {
+                // should continue if this fails
+            }
         }
         File osFontsDir;
         File psFontsDir;
@@ -111,20 +115,34 @@ public class WindowsFontDirFinder implem
             {
                 osFontsDir = new File(driveLetter + ":" + File.separator + windowsDirName
                         + File.separator + "FONTS");
-                if (osFontsDir.exists() && osFontsDir.canRead())
+                try
                 {
-                    fontDirList.add(osFontsDir);
-                    break;
+                    if (osFontsDir.exists() && osFontsDir.canRead())
+                    {
+                        fontDirList.add(osFontsDir);
+                        break;
+                    }
+                }
+                catch (SecurityException e)
+                {
+                    // should continue if this fails
                 }
             }
             // look for type 1 font folder
             for (char driveLetter = 'C'; driveLetter <= 'E'; driveLetter++)
             {
                 psFontsDir = new File(driveLetter + ":" + File.separator + "PSFONTS");
-                if (psFontsDir.exists() && psFontsDir.canRead())
+                try
+                {
+                    if (psFontsDir.exists() && psFontsDir.canRead())
+                    {
+                        fontDirList.add(psFontsDir);
+                        break;
+                    }
+                }
+                catch (SecurityException e)
                 {
-                    fontDirList.add(psFontsDir);
-                    break;
+                    // should continue if this fails
                 }
             }
         }

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java?rev=1763300&r1=1763299&r2=1763300&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java
Tue Oct  4 16:53:13 2016
@@ -285,7 +285,14 @@ final class FileSystemFontProvider exten
         try
         {
             File file = getDiskCacheFile();
-            writer = new BufferedWriter(new FileWriter(file));
+            try
+            {
+                writer = new BufferedWriter(new FileWriter(file));
+            }
+            catch (SecurityException e)
+            {
+                return;
+            }
 
             for (FSFontInfo fontInfo : fontInfoList)
             {
@@ -360,7 +367,15 @@ final class FileSystemFontProvider exten
         
         List<FSFontInfo> results = new ArrayList<FSFontInfo>();
         File file = getDiskCacheFile();
-        if (file.exists())
+        boolean fileExists = false;
+        try
+        {
+            fileExists = file.exists();
+        }
+        catch (SecurityException e)
+        {
+        }
+        if (fileExists)
         {
             BufferedReader reader = null;
             try



Mime
View raw message