jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r659095 - in /jackrabbit/trunk: jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/ jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/ jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/
Date Thu, 22 May 2008 12:53:24 GMT
Author: jukka
Date: Thu May 22 05:53:23 2008
New Revision: 659095

URL: http://svn.apache.org/viewvc?rev=659095&view=rev
Log:
JCR-1621: Use application/xml as the XML media type
    - Just ensure that the encoding is always UTF-8 for now
    - Use "text/xml; charset=UTF-8" in jackrabbit-webdav

Modified:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/SerializingContentHandler.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/XmlRequestEntity.java

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/SerializingContentHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/SerializingContentHandler.java?rev=659095&r1=659094&r2=659095&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/SerializingContentHandler.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/SerializingContentHandler.java
Thu May 22 05:53:23 2008
@@ -24,7 +24,9 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.sax.SAXTransformerFactory;
 import javax.xml.transform.sax.TransformerHandler;
@@ -55,6 +57,14 @@
  */
 public class SerializingContentHandler extends DefaultContentHandler {
 
+    /**
+     * The character encoding used for serialization (UTF-8).
+     * The encoding is fixed to make the text/xml content type safer to use.
+     *
+     * @see https://issues.apache.org/jira/browse/JCR-1621
+     */
+    public static final String ENCODING = "UTF-8";
+
     /** The URI for xml namespaces */
     private static final String XML = "http://www.w3.org/XML/1998/namespace";
 
@@ -98,6 +108,14 @@
             TransformerHandler handler = factory.newTransformerHandler();
             handler.setResult(result);
 
+            // Specify the output properties to avoid surprises especially in
+            // character encoding or the output method (might be html for some
+            // documents!)
+            Transformer transformer = handler.getTransformer();
+            transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+            transformer.setOutputProperty(OutputKeys.ENCODING, ENCODING);
+            transformer.setOutputProperty(OutputKeys.INDENT, "no");
+
             // Test whether the NamespaceAsAttributes wrapper is needed
             StringWriter writer = new StringWriter();
             TransformerHandler probe = factory.newTransformerHandler();

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java?rev=659095&r1=659094&r2=659095&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
Thu May 22 05:53:23 2008
@@ -165,8 +165,9 @@
                 transformer.transform(
                         new DOMSource(doc), new SAXResult(handler));
 
-                // TODO: application/xml?
-                httpResponse.setContentType("text/xml");
+                // TODO: Should this be application/xml? See JCR-1621
+                httpResponse.setContentType(
+                        "text/xml; charset=" + SerializingContentHandler.ENCODING);
                 httpResponse.setContentLength(out.size());
                 out.writeTo(httpResponse.getOutputStream());
             } catch (ParserConfigurationException e) {

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/XmlRequestEntity.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/XmlRequestEntity.java?rev=659095&r1=659094&r2=659095&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/XmlRequestEntity.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/XmlRequestEntity.java
Thu May 22 05:53:23 2008
@@ -65,7 +65,8 @@
     }
 
     public String getContentType() {
-        return "text/xml"; // TODO: Shouldn't this be application/xml?
+        // TODO: Shouldn't this be application/xml? See JCR-1621
+        return "text/xml; charset=" + SerializingContentHandler.ENCODING;
     }
 
     public void writeRequest(OutputStream out) throws IOException {



Mime
View raw message