abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r541071 - in /incubator/abdera/java/trunk: client/src/main/java/org/apache/abdera/protocol/client/ dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/ protocol/src/main/java/org/apache/abdera/protocol/util/ server/src/main/java/org/...
Date Wed, 23 May 2007 20:59:10 GMT
Author: jmsnell
Date: Wed May 23 13:59:09 2007
New Revision: 541071

URL: http://svn.apache.org/viewvc?view=rev&rev=541071
Log:
The next draft of the APP spec (15) changes the Slug header to use pct-encoding instead of
RFC2047.
This update accepts RFC2047 and pct-encoded headers, but makes it so that only pct-encoded
headers are produced.

Also, throw an error when the forbidden LF and CR characters are used in the slug.

Modified:
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/RequestOptions.java
    incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/Constants.java
    incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractRequest.java
    incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractResponse.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/AbstractResponseContext.java

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/RequestOptions.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/RequestOptions.java?view=diff&rev=541071&r1=541070&r2=541071
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/RequestOptions.java
(original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/RequestOptions.java
Wed May 23 13:59:09 2007
@@ -26,6 +26,8 @@
 
 import javax.activation.MimeType;
 
+import org.apache.abdera.i18n.iri.Constants;
+import org.apache.abdera.i18n.iri.Escaping;
 import org.apache.abdera.protocol.Request;
 import org.apache.abdera.protocol.util.AbstractRequest;
 import org.apache.abdera.protocol.util.CacheControlUtil;
@@ -379,14 +381,11 @@
    * Sets the value of the Atom Publishing Protocol Slug header
    */
   public void setSlug(String slug) {
-    setHeader("Slug", slug);
-  }
-  
-  /**
-   * Sets the value of the Atom Publishing Protocol Slug header
-   */
-  public void setSlug(String slug, String charset) {
-    setEncodedHeader("Slug", charset, slug);
+    if (slug.indexOf((char)10) > -1 ||
+        slug.indexOf((char)13) > -1)
+      throw new IllegalArgumentException(
+        "The slug must not contain ASCII carriage return or linefeed characters");
+    setHeader("Slug", Escaping.encode(slug,Constants.ASCIISANSCRLF));
   }
   
   /**

Modified: incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/Constants.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/Constants.java?view=diff&rev=541071&r1=541070&r2=541071
==============================================================================
--- incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/Constants.java
(original)
+++ incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/Constants.java
Wed May 23 13:59:09 2007
@@ -131,5 +131,8 @@
                                                 .set2(0x005B,0x0060)
                                                 .set2(0x007B,0x007F);
   
+  public final static BitSet ASCIISANSCRLF = new ChainableBitSet()
+                                                .set2(1, 127)
+                                                .clear2(10,13);
 
 }

Modified: incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractRequest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractRequest.java?view=diff&rev=541071&r1=541070&r2=541071
==============================================================================
--- incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractRequest.java
(original)
+++ incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractRequest.java
Wed May 23 13:59:09 2007
@@ -23,6 +23,7 @@
 import javax.activation.MimeType;
 import javax.activation.MimeTypeParseException;
 
+import org.apache.abdera.i18n.iri.Escaping;
 import org.apache.abdera.protocol.Request;
 
 public abstract class AbstractRequest implements Request {
@@ -57,7 +58,7 @@
   }
   
   public String getSlug() {
-    return EncodingUtil.decode(getHeader("Slug"));
+    return Escaping.decode(EncodingUtil.decode(getHeader("Slug")));
   }
 
   public MimeType getContentType() throws MimeTypeParseException {

Modified: incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractResponse.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractResponse.java?view=diff&rev=541071&r1=541070&r2=541071
==============================================================================
--- incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractResponse.java
(original)
+++ incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractResponse.java
Wed May 23 13:59:09 2007
@@ -24,6 +24,7 @@
 
 import org.apache.abdera.protocol.Response;
 import org.apache.abdera.util.EntityTag;
+import org.apache.abdera.i18n.iri.Escaping;
 import org.apache.abdera.i18n.iri.IRI;
 import org.apache.abdera.i18n.iri.IRISyntaxException;
 
@@ -192,7 +193,7 @@
   }
   
   public String getDecodedHeader(String header) {
-    return EncodingUtil.decode(getHeader(header));
+    return Escaping.decode(EncodingUtil.decode(getHeader(header)));
   }
   
 }

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/AbstractResponseContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/AbstractResponseContext.java?view=diff&rev=541071&r1=541070&r2=541071
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/AbstractResponseContext.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/AbstractResponseContext.java
Wed May 23 13:59:09 2007
@@ -23,6 +23,8 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.abdera.i18n.iri.Constants;
+import org.apache.abdera.i18n.iri.Escaping;
 import org.apache.abdera.protocol.server.provider.ResponseContext;
 import org.apache.abdera.protocol.util.AbstractResponse;
 import org.apache.abdera.protocol.util.EncodingUtil;
@@ -213,16 +215,16 @@
     setHeader("Content-Location", uri);
   }
   
-  public void setSlug(String slug, String charset) {
-    setSlug(EncodingUtil.encode(slug, charset));
-  }
-  
   public void setSlug(String slug) {
     if (slug == null) {
       removeHeader("Slug");
       return;
     }
-    setHeader("Slug", slug);
+    if (slug.indexOf((char)10) > -1 ||
+        slug.indexOf((char)13) > -1)
+      throw new IllegalArgumentException(
+        "The slug must not contain ASCII carriage return or linefeed characters");
+    setHeader("Slug", Escaping.encode(slug, Constants.ASCIISANSCRLF));
   }
   
   public void setContentType(String type) {



Mime
View raw message