You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by jy...@apache.org on 2005/03/10 16:25:03 UTC
cvs commit: xml-xalan/java/src/org/apache/xml/serializer CharInfo.java
jycli 2005/03/10 07:25:03
Modified: java/src/org/apache/xml/serializer CharInfo.java
Log:
Marked the code to be privileged, which allows users to load
customized entity files in sandbox. Fixed bug report XALANJ-2068.
Patch was reviewed by Brian Minchau (minchau@ca.ibm.com)
Revision Changes Path
1.18 +21 -5 xml-xalan/java/src/org/apache/xml/serializer/CharInfo.java
Index: CharInfo.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/CharInfo.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- CharInfo.java 16 Dec 2004 19:24:08 -0000 1.17
+++ CharInfo.java 10 Mar 2005 15:25:02 -0000 1.18
@@ -27,6 +27,8 @@
import java.util.Hashtable;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import javax.xml.transform.TransformerException;
@@ -459,7 +461,18 @@
// return isCleanTextASCII;
// }
-
+
+ private static CharInfo getCharInfoBasedOnPrivilege(
+ final String entitiesFileName, final String method,
+ final boolean internal){
+ return (CharInfo) AccessController.doPrivileged(
+ new PrivilegedAction() {
+ public Object run() {
+ return new CharInfo(entitiesFileName,
+ method, internal);}
+ });
+ }
+
/**
* Factory that reads in a resource file that describes the mapping of
* characters to entity references.
@@ -488,14 +501,16 @@
// try to load it internally - cache
try {
- charInfo = new CharInfo(entitiesFileName, method, true);
+ charInfo = getCharInfoBasedOnPrivilege(entitiesFileName,
+ method, true);
m_getCharInfoCache.put(entitiesFileName, charInfo);
return charInfo;
} catch (Exception e) {}
// try to load it externally - do not cache
try {
- return new CharInfo(entitiesFileName, method);
+ return getCharInfoBasedOnPrivilege(entitiesFileName,
+ method, false);
} catch (Exception e) {}
String absoluteEntitiesFileName;
@@ -512,7 +527,8 @@
}
}
- return new CharInfo(absoluteEntitiesFileName, method, false);
+ return getCharInfoBasedOnPrivilege(entitiesFileName,
+ method, false);
}
/** Table of user-specified char infos. */
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org