AccessController fix for getting the "line.separator"
system property. Applying Michael G.'s patch
from XALANJ-2341
diff --git a/src/org/apache/xml/serializer/ToStream.java b/src/org/apache/xml/serializer/ToStream.java
index 6b0637d..de5b2f8 100644
--- a/src/org/apache/xml/serializer/ToStream.java
+++ b/src/org/apache/xml/serializer/ToStream.java
@@ -105,10 +105,13 @@
* If m_doIndent is false this flag has no impact.
*/
protected boolean m_isprevtext = false;
-
- private static final char[] s_systemLineSep =
- System.getProperty("line.separator").toCharArray();
+ private static final char[] s_systemLineSep;
+ static {
+ SecuritySupport ss = SecuritySupport.getInstance();
+ s_systemLineSep = ss.getSystemProperty("line.separator").toCharArray();
+ }
+
/**
* The system line separator for writing out line breaks.
* The default value is from the system property,
diff --git a/src/org/apache/xml/serializer/dom3/LSSerializerImpl.java b/src/org/apache/xml/serializer/dom3/LSSerializerImpl.java
index 191032a..56c7aef 100644
--- a/src/org/apache/xml/serializer/dom3/LSSerializerImpl.java
+++ b/src/org/apache/xml/serializer/dom3/LSSerializerImpl.java
@@ -29,6 +29,8 @@
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.Properties;
import java.util.StringTokenizer;
@@ -70,7 +72,15 @@
// The default end-of-line character sequence used in serialization.
private static final String DEFAULT_END_OF_LINE;
static {
- String lineSeparator = System.getProperty("line.separator");
+ String lineSeparator = (String) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ try {
+ return System.getProperty("line.separator");
+ }
+ catch (SecurityException ex) {}
+ return null;
+ }
+ });
// The DOM Level 3 Load and Save specification requires that implementations choose a default
// sequence which matches one allowed by XML 1.0 (or XML 1.1). If the value of "line.separator"
// isn't one of the XML 1.0 end-of-line sequences then we select "\n" as the default value.