You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "James Phillpotts (JIRA)" <ji...@apache.org> on 2012/07/19 11:33:33 UTC

[jira] [Created] (SLING-2543) SlingPostServlet is not encoding redirect URLs

James Phillpotts created SLING-2543:
---------------------------------------

             Summary: SlingPostServlet is not encoding redirect URLs
                 Key: SLING-2543
                 URL: https://issues.apache.org/jira/browse/SLING-2543
             Project: Sling
          Issue Type: Bug
          Components: Servlets
    Affects Versions: Servlets Post 2.1.2
            Reporter: James Phillpotts
         Attachments: redirectencode.patch

According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."

The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.

e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13463677#comment-13463677 ] 

Carsten Ziegeler commented on SLING-2543:
-----------------------------------------

Thanks James, I agree that some test failures rather look strange, however reverting SLING-2543 makes all tests pass
                
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Bertrand Delacretaz
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: SLING-2543.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "James Phillpotts (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Phillpotts updated SLING-2543:
------------------------------------

    Attachment:     (was: SLING-2543.patch)
    
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Bertrand Delacretaz
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: new-redirect-integration-test.patch, SLING-2543-integration-tests-fix.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "Bertrand Delacretaz (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bertrand Delacretaz updated SLING-2543:
---------------------------------------

    Fix Version/s: Servlets Post 2.1.4
         Assignee: Bertrand Delacretaz
    
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Bertrand Delacretaz
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: SLING-2543.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Resolved] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler resolved SLING-2543.
-------------------------------------

    Resolution: Fixed
    
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Carsten Ziegeler
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: new-redirect-integration-test.patch, SLING-2543-integration-tests-fix.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13466671#comment-13466671 ] 

Carsten Ziegeler commented on SLING-2543:
-----------------------------------------

Unfortunately the post servlet is now tied to the latest api/resource resolver changes. So we can't release the post servlet before we released this. I think we're currently aiming for November as a release date for all this stuff
                
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Carsten Ziegeler
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: new-redirect-integration-test.patch, SLING-2543-integration-tests-fix.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "Julian Reschke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464647#comment-13464647 ] 

Julian Reschke commented on SLING-2543:
---------------------------------------

[~mrpotes] That sounds fishy -- why does the URI encoding affect the actual path?
                
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Bertrand Delacretaz
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: SLING-2543-integration-tests-fix.patch, SLING-2543.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "James Phillpotts (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Phillpotts updated SLING-2543:
------------------------------------

    Attachment: SLING-2543-integration-tests-fix.patch

Done :)
                
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Bertrand Delacretaz
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: new-redirect-integration-test.patch, SLING-2543-integration-tests-fix.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "James Phillpotts (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464640#comment-13464640 ] 

James Phillpotts edited comment on SLING-2543 at 9/27/12 10:33 PM:
-------------------------------------------------------------------

The fix was a little more complicated than expected - basically Sling's redirection was assuming that given a post path of "/abc/def/", a new node called "xyz" and a redirect of "*", then the returned path should be "/abc/def/xyz". However, the HttpServletResponse URL encoding sets it to /abc/xyz in this case.

As this is almost certainly a rule people will be expecting to be honoured (not least by the integration tests), I've made sure this rule is honoured when generating the redirection url.

The attached patch contains the necessary changes to SlingPostServlet and its test.
                
      was (Author: mrpotes):
    The fix was a little more complicated than expected - basically Sling's redirection was assuming that given a post path of "/abc/def/", a new node called "xyz" and a redirect of "*", then the returned path should be "/abc/def/xyz". However, the HttpServletResponse URL encoding sets it to /abc/xyz in this case.

As this is almost certainly a rule people will be expecting to be honoured (not least by the integration tests), I've made sure this rule is honoured when generating the redirection rule.

The attached patch contains the necessary changes to SlingPostServlet and its test.
                  
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Bertrand Delacretaz
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: SLING-2543-integration-tests-fix.patch, SLING-2543.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Assigned] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler reassigned SLING-2543:
---------------------------------------

    Assignee: Carsten Ziegeler  (was: Bertrand Delacretaz)
    
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Carsten Ziegeler
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: new-redirect-integration-test.patch, SLING-2543-integration-tests-fix.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "James Phillpotts (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Phillpotts updated SLING-2543:
------------------------------------

    Attachment: new-redirect-integration-test.patch

Attached is another patch that adds a new test method to the PostRedirectTest class. (patch is relative to trunk/launchpad/integration-tests)
                
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Bertrand Delacretaz
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: new-redirect-integration-test.patch, SLING-2543-integration-tests-fix.patch, SLING-2543.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464743#comment-13464743 ] 

Carsten Ziegeler commented on SLING-2543:
-----------------------------------------

Thanks James for your patches - I just realized too late that you already had the patch and committed different changes to the post servlet, therefore your first patch is not applyable aynmore. Could you please recreate this patch?
                
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Bertrand Delacretaz
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: new-redirect-integration-test.patch, SLING-2543-integration-tests-fix.patch, SLING-2543.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "James Phillpotts (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464783#comment-13464783 ] 

James Phillpotts commented on SLING-2543:
-----------------------------------------

I've deleted the old patch too.
                
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Bertrand Delacretaz
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: new-redirect-integration-test.patch, SLING-2543-integration-tests-fix.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "James Phillpotts (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464813#comment-13464813 ] 

James Phillpotts commented on SLING-2543:
-----------------------------------------

No problem. Any idea when a release of the post servlet bundle might be done?
                
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Carsten Ziegeler
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: new-redirect-integration-test.patch, SLING-2543-integration-tests-fix.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464810#comment-13464810 ] 

Carsten Ziegeler commented on SLING-2543:
-----------------------------------------

Thanks again for your patches, James. I've applied both of them

                
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Carsten Ziegeler
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: new-redirect-integration-test.patch, SLING-2543-integration-tests-fix.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "James Phillpotts (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464698#comment-13464698 ] 

James Phillpotts commented on SLING-2543:
-----------------------------------------

It does a bit, doesn't it (I didn't dwell on *why* when I was trying to fix the tests, whoops). I'll see if I can track down where/why that's happening.
                
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Bertrand Delacretaz
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: SLING-2543-integration-tests-fix.patch, SLING-2543.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "James Phillpotts (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Phillpotts updated SLING-2543:
------------------------------------

    Attachment:     (was: SLING-2543-integration-tests-fix.patch)
    
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Bertrand Delacretaz
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: new-redirect-integration-test.patch, SLING-2543-integration-tests-fix.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "James Phillpotts (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464714#comment-13464714 ] 

James Phillpotts commented on SLING-2543:
-----------------------------------------

Ah-ha, I was wrong - it's SlingHttpServletResponseImpl that was doing that:

    private String makeAbsolutePath(String path) {
        if (path.startsWith("/")) {
            return path;
        }

        String base = getRequestData().getContentData().getResource().getPath();
        int lastSlash = base.lastIndexOf('/');
        if (lastSlash >= 0) {
            path = base.substring(0, lastSlash+1) + path;
        } else {
            path = "/" + path;
        }

        return path;
    }

In the case of a create post ending in / at the end, the getRequestData().getContentData().getResource().getPath() returns /abc/def (rather than /abc/def/). This method is called from SlingHttpServletResponseImpl.encodeRedirectURL.
                
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Bertrand Delacretaz
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: SLING-2543-integration-tests-fix.patch, SLING-2543.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "James Phillpotts (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Phillpotts updated SLING-2543:
------------------------------------

    Attachment: SLING-2543.patch

Updated patch, includes unit test
                
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>         Attachments: SLING-2543.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Resolved] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "Bertrand Delacretaz (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bertrand Delacretaz resolved SLING-2543.
----------------------------------------

    Resolution: Fixed

Patch committed with minor changes in revision 1369828, thanks!
                
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Bertrand Delacretaz
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: SLING-2543.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Updated] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "James Phillpotts (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Phillpotts updated SLING-2543:
------------------------------------

    Attachment: SLING-2543-integration-tests-fix.patch

The fix was a little more complicated than expected - basically Sling's redirection was assuming that given a post path of "/abc/def/", a new node called "xyz" and a redirect of "*", then the returned path should be "/abc/def/xyz". However, the HttpServletResponse URL encoding sets it to /abc/xyz in this case.

As this is almost certainly a rule people will be expecting to be honoured (not least by the integration tests), I've made sure this rule is honoured when generating the redirection rule.

The attached patch contains the necessary changes to SlingPostServlet and its test.
                
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Bertrand Delacretaz
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: SLING-2543-integration-tests-fix.patch, SLING-2543.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "James Phillpotts (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Phillpotts updated SLING-2543:
------------------------------------

    Attachment: redirectencode.patch

Patch for suggested fix
                
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>         Attachments: redirectencode.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "James Phillpotts (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13463654#comment-13463654 ] 

James Phillpotts commented on SLING-2543:
-----------------------------------------

Hi Carsten, I can see quite a lot of test failures (I'm looking here - I guess this is right? https://builds.apache.org/view/S-Z/view/Sling/job/sling-trunk-1.6/), most of which don't seem to have anything to do with this. I assume you mean these 3:

testForcedRedirect(org.apache.sling.launchpad.webapp.integrationtest.PostRedirectTest): With forced redirect and Referer, redirect must be forced expected:<http://[]forced> but was:<http://[localhost:46258/CreateNodeTest/1348606571797/_http_//]forced>
  testDefaultRedirect(org.apache.sling.launchpad.webapp.integrationtest.PostRedirectTest): With no headers or parameters, redirect (http://localhost:46258/CreateNodeTest/37_1348606597735) must point to created node (path=CreateNodeTest/1348606571797)
  testMagicStarRedirect(org.apache.sling.launchpad.webapp.integrationtest.PostRedirectTest): With magic star, redirect (http://localhost:46258/CreateNodeTest/38_1348606597742) must point to created node (path=CreateNodeTest/1348606571797)

Of these, I'm not sure I understand the second and third - prefixes 37_ and 38_ seem to have been added in the middle of the URL - I can't see that encoding the returned URL would do this. The first looks like it might be a bug in Jetty 6 that looks like it might be fixed in Jetty 8 - we can strip of the pre-path part of the URL and reattach after encoding?

It would also be useful if the redirection included debug logging so that one could trace what was being returned as the redirect URL.

I'll add a new patch to do these two things shortly.
                
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Bertrand Delacretaz
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: SLING-2543.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "James Phillpotts (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Phillpotts updated SLING-2543:
------------------------------------

    Attachment:     (was: redirectencode.patch)
    
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>         Attachments: SLING-2543.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Reopened] (SLING-2543) SlingPostServlet is not encoding redirect URLs

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2543?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler reopened SLING-2543:
-------------------------------------


It seems that some integration tests are failing because of this change
                
> SlingPostServlet is not encoding redirect URLs
> ----------------------------------------------
>
>                 Key: SLING-2543
>                 URL: https://issues.apache.org/jira/browse/SLING-2543
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>    Affects Versions: Servlets Post 2.1.2
>            Reporter: James Phillpotts
>            Assignee: Bertrand Delacretaz
>             Fix For: Servlets Post 2.1.4
>
>         Attachments: SLING-2543.patch
>
>
> According to the JavaEE documentation for HttpServletResponse.encodeRedirectURL, "All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method."
> The SlingPostServlet isn't doing this, and so if you try and redirect to a node that contains special characters in the name, the redirect URL is incorrect.
> e.g. A post request containing :name of Друга and :redirect of *.html gets a redirect URL of ?????.html rather than %D0%94%D1%80%D1%83%D0%B3%D0%B0.html as would be expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira