You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by ca...@apache.org on 2006/12/06 07:57:28 UTC

svn commit: r482928 - in /xmlgraphics/batik/trunk/sources/org/apache/batik: bridge/BaseScriptingEnvironment.java util/ParsedURL.java util/ParsedURLData.java

Author: cam
Date: Tue Dec  5 22:57:25 2006
New Revision: 482928

URL: http://svn.apache.org/viewvc?view=rev&rev=482928
Log:
1. Actually comply to RFC 4329 (by considering application/ecmascript resources
   with version parameters to be unsupported).
2. Remove waylaid debugging statement.

Modified:
    xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/BaseScriptingEnvironment.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/util/ParsedURL.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/util/ParsedURLData.java

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/BaseScriptingEnvironment.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/BaseScriptingEnvironment.java?view=diff&rev=482928&r1=482927&r2=482928
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/BaseScriptingEnvironment.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/BaseScriptingEnvironment.java Tue Dec  5 22:57:25 2006
@@ -432,6 +432,13 @@
                         if (mediaType.equals(APPLICATION_ECMASCRIPT)) {
                             // No encoding was specified in the MIME type, so
                             // infer it according to RFC 4329.
+                            if (purl.hasContentTypeParameter("version")) {
+                                // Future versions of application/ecmascript are
+                                // not supported, so skip this script element if
+                                // the version parameter is present.
+                                continue;
+                            }
+
                             PushbackInputStream pbis =
                                 new PushbackInputStream(is, 8);
                             byte[] buf = new byte[4];

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/util/ParsedURL.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/util/ParsedURL.java?view=diff&rev=482928&r1=482927&r2=482928
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/util/ParsedURL.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/util/ParsedURL.java Tue Dec  5 22:57:25 2006
@@ -359,6 +359,13 @@
     }
 
     /**
+     * Returns whether the Content-Type header has the given parameter.
+     */
+    public boolean hasContentTypeParameter(String param) {
+        return data.hasContentTypeParameter(userAgent, param);
+    }
+
+    /**
      * Returns the content encoding if available.  This is only available
      * for some protocols.
      */

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/util/ParsedURLData.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/util/ParsedURLData.java?view=diff&rev=482928&r1=482927&r2=482928
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/util/ParsedURLData.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/util/ParsedURLData.java Tue Dec  5 22:57:25 2006
@@ -316,6 +316,52 @@
     }
 
     /**
+     * Returns whether the Content-Type header has the given parameter.
+     */
+    public boolean hasContentTypeParameter(String userAgent, String param) {
+        getContentType(userAgent);
+        int i = 0;
+        int len = contentType.length();
+        int plen = param.length();
+loop1:  while (i < len) {
+            switch (contentType.charAt(i)) {
+                case ' ':
+                case ';':
+                    break loop1;
+            }
+            i++;
+        }
+        if (i == len) {
+            contentTypeMediaType = contentType;
+        } else {
+            contentTypeMediaType = contentType.substring(0, i);
+        }
+loop2:  for (;;) {
+            while (i < len && contentType.charAt(i) != ';') {
+                i++;
+            }
+            if (i == len) {
+                return false;
+            }
+            i++;
+            while (i < len && contentType.charAt(i) == ' ') {
+                i++;
+            }
+            if (i >= len - plen - 1) {
+                return false;
+            }
+            for (int j = 0; j < plen; j++) {
+                if (!(contentType.charAt(i++) == param.charAt(j))) {
+                    continue loop2;
+                }
+            }
+            if (contentType.charAt(i) == '=') {
+                return true;
+            }
+        }
+    }
+
+    /**
      * Extracts the type/subtype and charset parameter from the Content-Type
      * header.
      */
@@ -331,7 +377,6 @@
             }
             i++;
         }
-        System.err.println("i == " + i);
         if (i == len) {
             contentTypeMediaType = contentType;
         } else {



Re: svn commit: r482928 - in /xmlgraphics/batik/trunk/sources/org/apache/batik: bridge/BaseScriptingEnvironment.java util/ParsedURL.java util/ParsedURLData.java

Posted by Cameron McCormack <ca...@mcc.id.au>.
Cameron McCormack:
> 1. Actually comply to RFC 4329 (by considering application/ecmascript resources
>    with version parameters to be unsupported).

“comply _with_”…

*has another beer*

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au