tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mikaël Cluseau (JIRA) <tapestry-...@jakarta.apache.org>
Subject [jira] Created: (TAPESTRY-280) DataSqueezer should URLEncode/Decode its string
Date Wed, 09 Mar 2005 23:37:53 GMT
DataSqueezer should URLEncode/Decode its string

         Key: TAPESTRY-280
         URL: http://issues.apache.org/jira/browse/TAPESTRY-280
     Project: Tapestry
        Type: Bug
  Components: Framework  
    Versions: 3.0, 3.0.1, 3.1, 3.0.2    
 Environment: Java AMD64 1.5.01
    Reporter: Mikaël Cluseau

I would add a fix in the DataSqueezer: the current implementation allow
Strings like "abc&sp=def" directly in the URL, which creates a second
parameter where only one is expected.

This is very inconvenient when you squeeze callback URLs (I have a
RedirectCallback that squeezes to R{url}). The bug is not obvious (I
first tought the browser was "pretty printing" the URL) as the "?" is
not considered a parameter so, if you have
Login.tap?sp=R/List.tap?sp=1&sp=2, the callback's URL becomes
"/List.tap?sp=1" and you have a second parameter to your Login page...

I think the correct way of encoding parameters is :

// TODO For Java 1.3 compatibility, use equivalents from commons-codecs
import java.net.URLEncoder;
import java.net.URLDecoder;
public class DataSqueezer {
    public String squeeze(Object data) throws IOException
        ISqueezeAdaptor adaptor;

        if (data == null)
            return NULL_PREFIX;

        adaptor = (ISqueezeAdaptor) _adaptors.getAdaptor(data.getClass());

        return URLEncoder.encode(adaptor.squeeze(this, data),"UTF-8");
    public Object unsqueeze(String rawString) throws IOException
        ISqueezeAdaptor adaptor = null;

        String string = URLDecoder.decode(rawString, "UTF-8");

        if (string.equals(NULL_PREFIX))
            return null;

        int offset = string.charAt(0) - FIRST_ADAPTOR_OFFSET;

        if (offset >= 0 && offset < _adaptorByPrefix.length)
            adaptor = _adaptorByPrefix[offset];

        // If the adaptor is not otherwise recognized, the it is simply
        // an encoded String (the StringAdaptor may not have added
        // a prefix).

        if (adaptor == null)
            return string;

        // Adaptor should never be null, because we always supply
        // an adaptor for String

        return adaptor.unsqueeze(this, string);

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
If you want more information on JIRA, or have a bug to report see:

To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org

View raw message