You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Dmitry Grytsovets (JIRA)" <ji...@apache.org> on 2011/01/14 13:29:46 UTC

[jira] Created: (HTTPCLIENT-1043) BasicPathHandler match bug

BasicPathHandler match bug
--------------------------

                 Key: HTTPCLIENT-1043
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1043
             Project: HttpComponents HttpClient
          Issue Type: Bug
          Components: HttpClient
    Affects Versions: 4.1 Beta1, 4.1 Alpha2, 4.1 Alpha1, 4.0.3, 4.0.2, 4.0.1
            Reporter: Dmitry Grytsovets
            Priority: Critical
             Fix For: 4.1.0, Future


in BasicPathHandler

   boolean match = targetpath.startsWith (topmostPath);
        // if there is a match and these values are not exactly the same we have
        // to make sure we're not matcing "/foobar" and "/foo"
        if (match && targetpath.length() != topmostPath.length()) {
            if (!topmostPath.endsWith("/")) {
                match = (targetpath.charAt(topmostPath.length()) == '/');
            }
        }

must be changed to

   boolean match = topmostPath.startsWith (targetpath);
        // if there is a match and these values are not exactly the same we have
        // to make sure we're not matcing "/foobar" and "/foo"
        if (match && targetpath.length() != topmostPath.length()) {
            if (!topmostPath.endsWith("/")) {
                match = (topmostPath.charAt(targetpath.length()) == '/');
            }
        }

example 

targetpath = "/stat/" // where are you
topmostPath  = "/stat/domain.tld/" // cookie for path

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCLIENT-1043) BasicPathHandler match bug

Posted by "Dmitry Grytsovets (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12981787#action_12981787 ] 

Dmitry Grytsovets commented on HTTPCLIENT-1043:
-----------------------------------------------

For example liveinternet.ru uses /stat/domain.tld/ cookies to store access rights cookies for domain.tld , and you can't login with  HttpClient

> BasicPathHandler match bug
> --------------------------
>
>                 Key: HTTPCLIENT-1043
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1043
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpCookie
>    Affects Versions: 4.0.1, 4.0.2, 4.0.3, 4.1 Alpha1, 4.1 Alpha2, 4.1 Beta1
>            Reporter: Dmitry Grytsovets
>            Priority: Minor
>
> in BasicPathHandler
>    boolean match = targetpath.startsWith (topmostPath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!topmostPath.endsWith("/")) {
>                 match = (targetpath.charAt(topmostPath.length()) == '/');
>             }
>         }
> must be changed to
>    boolean match = topmostPath.startsWith (targetpath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!targetPath.endsWith("/")) {
>                 match = (topmostPath.charAt(targetpath.length()-1) == '/');
>             }
>         }
> example 
> targetpath = "/stat/" // where are you
> topmostPath  = "/stat/domain.tld/" // cookie for path

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Issue Comment Edited: (HTTPCLIENT-1043) BasicPathHandler match bug

Posted by "Dmitry Grytsovets (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12981769#action_12981769 ] 

Dmitry Grytsovets edited comment on HTTPCLIENT-1043 at 1/14/11 9:39 AM:
------------------------------------------------------------------------

       @Test
	public void testCookieReadAndSend() throws Exception {
		BasicHeader header = new BasicHeader("Set-Cookie",
				"cookie-name=cookie-value; domain=127.0.0.1; path=/d1/d2");

		CookieSpec cookiespec = new RFC2109Spec();
		CookieOrigin readOrigin = new CookieOrigin("127.0.0.1", 80, "/d1", false);
		//this part must be fixed  
		List<Cookie> cookies = cookiespec.parse(header, readOrigin);
		try {
			for (int i = 0; i < cookies.size(); i++) {
				cookiespec.validate(cookies.get(i), readOrigin);
			}
		} catch (MalformedCookieException e) {
			Assert.fail("MalformedCookieException exception should havn't been thrown");
		}
		//next part  works now
		try {
			CookieOrigin sendOrigin = new CookieOrigin("127.0.0.1", 80, "/d1/d2/d3/", false);
			for (int i = 0; i < cookies.size(); i++) {
				cookiespec.validate(cookies.get(i), sendOrigin);
			}
		} catch (MalformedCookieException e) {
			Assert.fail("MalformedCookieException exception should havn't been thrown");
		}


	}



      was (Author: dgreen):
           @Test
	public void testCookieReadAndSend() throws Exception {
		BasicHeader header = new BasicHeader("Set-Cookie",
				"cookie-name=cookie-value; domain=127.0.0.1; path=/d1/d2");

		CookieSpec cookiespec = new RFC2109Spec();
		CookieOrigin readOrigin = new CookieOrigin("127.0.0.1", 80, "/d1", false);
		//this part must be fixed  
		List<Cookie> cookies = cookiespec.parse(header, readOrigin);
		try {
			for (int i = 0; i < cookies.size(); i++) {
				cookiespec.validate(cookies.get(i), readOrigin);
			}
		} catch (MalformedCookieException e) {
			Assert.fail("MalformedCookieException exception should havn't been thrown");
		}
		//next part  works now
		try {
			CookieOrigin sendOrigin = new CookieOrigin("127.0.0.1", 80, "/d1/d2/d3/", false);
			for (int i = 0; i < cookies.size(); i++) {
				cookiespec.validate(cookies.get(i), readOrigin);
			}
		} catch (MalformedCookieException e) {
			Assert.fail("MalformedCookieException exception should havn't been thrown");
		}


	}


  
> BasicPathHandler match bug
> --------------------------
>
>                 Key: HTTPCLIENT-1043
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1043
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpCookie
>    Affects Versions: 4.0.1, 4.0.2, 4.0.3, 4.1 Alpha1, 4.1 Alpha2, 4.1 Beta1
>            Reporter: Dmitry Grytsovets
>            Priority: Minor
>             Fix For: 4.1.0, Future
>
>
> in BasicPathHandler
>    boolean match = targetpath.startsWith (topmostPath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!topmostPath.endsWith("/")) {
>                 match = (targetpath.charAt(topmostPath.length()) == '/');
>             }
>         }
> must be changed to
>    boolean match = topmostPath.startsWith (targetpath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!targetPath.endsWith("/")) {
>                 match = (topmostPath.charAt(targetpath.length()-1) == '/');
>             }
>         }
> example 
> targetpath = "/stat/" // where are you
> topmostPath  = "/stat/domain.tld/" // cookie for path

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCLIENT-1043) BasicPathHandler match bug

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12981801#action_12981801 ] 

Oleg Kalnichevski commented on HTTPCLIENT-1043:
-----------------------------------------------

And it is being absolutely right about rejecting such a cookie given the fact you are using the RFC 2109 cookie policy. However, if the cookie is accepted by common browsers (IE, FF), we may have to tweak the browser compatibility policy to match this non-standard behavior.

Oleg 

> BasicPathHandler match bug
> --------------------------
>
>                 Key: HTTPCLIENT-1043
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1043
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpCookie
>    Affects Versions: 4.0.1, 4.0.2, 4.0.3, 4.1 Alpha1, 4.1 Alpha2, 4.1 Beta1
>            Reporter: Dmitry Grytsovets
>            Priority: Minor
>
> in BasicPathHandler
>    boolean match = targetpath.startsWith (topmostPath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!topmostPath.endsWith("/")) {
>                 match = (targetpath.charAt(topmostPath.length()) == '/');
>             }
>         }
> must be changed to
>    boolean match = topmostPath.startsWith (targetpath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!targetPath.endsWith("/")) {
>                 match = (topmostPath.charAt(targetpath.length()-1) == '/');
>             }
>         }
> example 
> targetpath = "/stat/" // where are you
> topmostPath  = "/stat/domain.tld/" // cookie for path

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCLIENT-1043) BasicPathHandler match bug

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12981784#action_12981784 ] 

Oleg Kalnichevski commented on HTTPCLIENT-1043:
-----------------------------------------------

The HTTP specification clearly states that the path attribute must be a prefix of the request-URI. See the extracts above. Therefore a cookie with the path "/d1/d2" can be sent to "/d1/d2/d3" but cannot be sent to "/d1".

If your application needs to be compatible with broken web sites that violate the HTTP specification, you can implement a custom cookie spec or override the path matching logic of the default implementation. 

Oleg 

> BasicPathHandler match bug
> --------------------------
>
>                 Key: HTTPCLIENT-1043
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1043
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpCookie
>    Affects Versions: 4.0.1, 4.0.2, 4.0.3, 4.1 Alpha1, 4.1 Alpha2, 4.1 Beta1
>            Reporter: Dmitry Grytsovets
>            Priority: Minor
>
> in BasicPathHandler
>    boolean match = targetpath.startsWith (topmostPath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!topmostPath.endsWith("/")) {
>                 match = (targetpath.charAt(topmostPath.length()) == '/');
>             }
>         }
> must be changed to
>    boolean match = topmostPath.startsWith (targetpath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!targetPath.endsWith("/")) {
>                 match = (topmostPath.charAt(targetpath.length()-1) == '/');
>             }
>         }
> example 
> targetpath = "/stat/" // where are you
> topmostPath  = "/stat/domain.tld/" // cookie for path

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (HTTPCLIENT-1043) BasicPathHandler match bug

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

Dmitry Grytsovets updated HTTPCLIENT-1043:
------------------------------------------

    Description: 
in BasicPathHandler

   boolean match = targetpath.startsWith (topmostPath);
        // if there is a match and these values are not exactly the same we have
        // to make sure we're not matcing "/foobar" and "/foo"
        if (match && targetpath.length() != topmostPath.length()) {
            if (!topmostPath.endsWith("/")) {
                match = (targetpath.charAt(topmostPath.length()) == '/');
            }
        }

must be changed to

   boolean match = topmostPath.startsWith (targetpath);
        // if there is a match and these values are not exactly the same we have
        // to make sure we're not matcing "/foobar" and "/foo"
        if (match && targetpath.length() != topmostPath.length()) {
            if (!targetPath.endsWith("/")) {
                match = (topmostPath.charAt(targetpath.length()-1) == '/');
            }
        }

example 

targetpath = "/stat/" // where are you
topmostPath  = "/stat/domain.tld/" // cookie for path

  was:
in BasicPathHandler

   boolean match = targetpath.startsWith (topmostPath);
        // if there is a match and these values are not exactly the same we have
        // to make sure we're not matcing "/foobar" and "/foo"
        if (match && targetpath.length() != topmostPath.length()) {
            if (!topmostPath.endsWith("/")) {
                match = (targetpath.charAt(topmostPath.length()) == '/');
            }
        }

must be changed to

   boolean match = topmostPath.startsWith (targetpath);
        // if there is a match and these values are not exactly the same we have
        // to make sure we're not matcing "/foobar" and "/foo"
        if (match && targetpath.length() != topmostPath.length()) {
            if (!topmostPath.endsWith("/")) {
                match = (topmostPath.charAt(targetpath.length()) == '/');
            }
        }

example 

targetpath = "/stat/" // where are you
topmostPath  = "/stat/domain.tld/" // cookie for path


> BasicPathHandler match bug
> --------------------------
>
>                 Key: HTTPCLIENT-1043
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1043
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.0.1, 4.0.2, 4.0.3, 4.1 Alpha1, 4.1 Alpha2, 4.1 Beta1
>            Reporter: Dmitry Grytsovets
>            Priority: Critical
>             Fix For: 4.1.0, Future
>
>
> in BasicPathHandler
>    boolean match = targetpath.startsWith (topmostPath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!topmostPath.endsWith("/")) {
>                 match = (targetpath.charAt(topmostPath.length()) == '/');
>             }
>         }
> must be changed to
>    boolean match = topmostPath.startsWith (targetpath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!targetPath.endsWith("/")) {
>                 match = (topmostPath.charAt(targetpath.length()-1) == '/');
>             }
>         }
> example 
> targetpath = "/stat/" // where are you
> topmostPath  = "/stat/domain.tld/" // cookie for path

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCLIENT-1043) BasicPathHandler match bug

Posted by "Dmitry Grytsovets (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12981769#action_12981769 ] 

Dmitry Grytsovets commented on HTTPCLIENT-1043:
-----------------------------------------------

       @Test
	public void testCookieReadAndSend() throws Exception {
		BasicHeader header = new BasicHeader("Set-Cookie",
				"cookie-name=cookie-value; domain=127.0.0.1; path=/d1/d2");

		CookieSpec cookiespec = new RFC2109Spec();
		CookieOrigin readOrigin = new CookieOrigin("127.0.0.1", 80, "/d1", false);
		//this part must be fixed  
		List<Cookie> cookies = cookiespec.parse(header, readOrigin);
		try {
			for (int i = 0; i < cookies.size(); i++) {
				cookiespec.validate(cookies.get(i), readOrigin);
			}
		} catch (MalformedCookieException e) {
			Assert.fail("MalformedCookieException exception should havn't been thrown");
		}
		//next part  works now
		try {
			CookieOrigin sendOrigin = new CookieOrigin("127.0.0.1", 80, "/d1/d2/d3/", false);
			for (int i = 0; i < cookies.size(); i++) {
				cookiespec.validate(cookies.get(i), readOrigin);
			}
		} catch (MalformedCookieException e) {
			Assert.fail("MalformedCookieException exception should havn't been thrown");
		}


	}



> BasicPathHandler match bug
> --------------------------
>
>                 Key: HTTPCLIENT-1043
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1043
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpCookie
>    Affects Versions: 4.0.1, 4.0.2, 4.0.3, 4.1 Alpha1, 4.1 Alpha2, 4.1 Beta1
>            Reporter: Dmitry Grytsovets
>            Priority: Minor
>             Fix For: 4.1.0, Future
>
>
> in BasicPathHandler
>    boolean match = targetpath.startsWith (topmostPath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!topmostPath.endsWith("/")) {
>                 match = (targetpath.charAt(topmostPath.length()) == '/');
>             }
>         }
> must be changed to
>    boolean match = topmostPath.startsWith (targetpath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!targetPath.endsWith("/")) {
>                 match = (topmostPath.charAt(targetpath.length()-1) == '/');
>             }
>         }
> example 
> targetpath = "/stat/" // where are you
> topmostPath  = "/stat/domain.tld/" // cookie for path

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Resolved: (HTTPCLIENT-1043) BasicPathHandler match bug

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

Oleg Kalnichevski resolved HTTPCLIENT-1043.
-------------------------------------------

       Resolution: Invalid
    Fix Version/s:     (was: 4.1.0)
                       (was: Future)

RFC 2965 [1]

---
1.  TERMINOLOGY
...

   For two strings that represent paths, P1 and P2, P1 path-matches P2
   if P2 is a prefix of P1 (including the case where P1 and P2 string-
   compare equal).  Thus, the string /tec/waldo path-matches /tec.

---

---
   3.3.2  Rejecting Cookies  
...

   A user agent rejects (SHALL NOT store its information) if the Version
   attribute is missing.  Moreover, a user agent rejects (SHALL NOT
   store its information) if any of the following is true of the
   attributes explicitly present in the Set-Cookie2 response header:

      *  The value for the Path attribute is not a prefix of the
         request-URI.
...
---

[1] http://www.faqs.org/rfcs/rfc2965.html

> BasicPathHandler match bug
> --------------------------
>
>                 Key: HTTPCLIENT-1043
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1043
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpCookie
>    Affects Versions: 4.0.1, 4.0.2, 4.0.3, 4.1 Alpha1, 4.1 Alpha2, 4.1 Beta1
>            Reporter: Dmitry Grytsovets
>            Priority: Minor
>
> in BasicPathHandler
>    boolean match = targetpath.startsWith (topmostPath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!topmostPath.endsWith("/")) {
>                 match = (targetpath.charAt(topmostPath.length()) == '/');
>             }
>         }
> must be changed to
>    boolean match = topmostPath.startsWith (targetpath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!targetPath.endsWith("/")) {
>                 match = (topmostPath.charAt(targetpath.length()-1) == '/');
>             }
>         }
> example 
> targetpath = "/stat/" // where are you
> topmostPath  = "/stat/domain.tld/" // cookie for path

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCLIENT-1043) BasicPathHandler match bug

Posted by "Dmitry Grytsovets (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12981790#action_12981790 ] 

Dmitry Grytsovets commented on HTTPCLIENT-1043:
-----------------------------------------------

> The HTTP specification clearly states that the path attribute must be a prefix of the request-URI. See the extracts above. Therefore a cookie with the path "/d1/d2" can be sent to "/d1/d2/d3" but cannot be sent to "/d1".

> If your application needs to be compatible with broken web sites that violate the HTTP specification, you can implement a custom cookie spec or override the path matching logic of the default implementation. 


Simple scenario,
You on page http://localhost/stat/
When you enter password for domain.tld, page http://localhost/stat/ trying to set cookie for http://localhost/stat/domain.tld/
Current version of client  REJECT this cookies
As you can see in my test

CookieSpec cookiespec = new RFC2109Spec();
//login page
CookieOrigin readOrigin = new CookieOrigin("127.0.0.1", 80, "/d1", false); 
//trying to set cookies for it's CHILD
BasicHeader header = new BasicHeader("Set-Cookie",
"cookie-name=cookie-value; domain=127.0.0.1; path=/d1/d2"); 
//this part must be fixed
List<Cookie> cookies = cookiespec.parse(header, readOrigin);
try {
for (int i = 0; i < cookies.size(); i++) {
cookiespec.validate(cookies.get(i), readOrigin);
}
} catch (MalformedCookieException e) {
//BUT CLIENT REJECTS IT
Assert.fail("MalformedCookieException exception should havn't been thrown");
} 

> BasicPathHandler match bug
> --------------------------
>
>                 Key: HTTPCLIENT-1043
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1043
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpCookie
>    Affects Versions: 4.0.1, 4.0.2, 4.0.3, 4.1 Alpha1, 4.1 Alpha2, 4.1 Beta1
>            Reporter: Dmitry Grytsovets
>            Priority: Minor
>
> in BasicPathHandler
>    boolean match = targetpath.startsWith (topmostPath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!topmostPath.endsWith("/")) {
>                 match = (targetpath.charAt(topmostPath.length()) == '/');
>             }
>         }
> must be changed to
>    boolean match = topmostPath.startsWith (targetpath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!targetPath.endsWith("/")) {
>                 match = (topmostPath.charAt(targetpath.length()-1) == '/');
>             }
>         }
> example 
> targetpath = "/stat/" // where are you
> topmostPath  = "/stat/domain.tld/" // cookie for path

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCLIENT-1043) BasicPathHandler match bug

Posted by "Dmitry Grytsovets (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12981741#action_12981741 ] 

Dmitry Grytsovets commented on HTTPCLIENT-1043:
-----------------------------------------------

but this fix will broke checkin RequestAddCookies, so BasicPathHandler must be different for cookie sending and receiving

> BasicPathHandler match bug
> --------------------------
>
>                 Key: HTTPCLIENT-1043
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1043
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.0.1, 4.0.2, 4.0.3, 4.1 Alpha1, 4.1 Alpha2, 4.1 Beta1
>            Reporter: Dmitry Grytsovets
>            Priority: Critical
>             Fix For: 4.1.0, Future
>
>
> in BasicPathHandler
>    boolean match = targetpath.startsWith (topmostPath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!topmostPath.endsWith("/")) {
>                 match = (targetpath.charAt(topmostPath.length()) == '/');
>             }
>         }
> must be changed to
>    boolean match = topmostPath.startsWith (targetpath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!targetPath.endsWith("/")) {
>                 match = (topmostPath.charAt(targetpath.length()-1) == '/');
>             }
>         }
> example 
> targetpath = "/stat/" // where are you
> topmostPath  = "/stat/domain.tld/" // cookie for path

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (HTTPCLIENT-1043) BasicPathHandler match bug

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

Oleg Kalnichevski updated HTTPCLIENT-1043:
------------------------------------------

    Component/s:     (was: HttpClient)
                 HttpCookie
       Priority: Minor  (was: Critical)

Dmitry

Could you please produce a complete wire log of the HTTP session that exhibits the problem? You might also want to add a test case to the HttpClient test suite [1] that demonstrates the problem.

Oleg  

[1] http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2109Spec.java

> BasicPathHandler match bug
> --------------------------
>
>                 Key: HTTPCLIENT-1043
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1043
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpCookie
>    Affects Versions: 4.0.1, 4.0.2, 4.0.3, 4.1 Alpha1, 4.1 Alpha2, 4.1 Beta1
>            Reporter: Dmitry Grytsovets
>            Priority: Minor
>             Fix For: 4.1.0, Future
>
>
> in BasicPathHandler
>    boolean match = targetpath.startsWith (topmostPath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!topmostPath.endsWith("/")) {
>                 match = (targetpath.charAt(topmostPath.length()) == '/');
>             }
>         }
> must be changed to
>    boolean match = topmostPath.startsWith (targetpath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!targetPath.endsWith("/")) {
>                 match = (topmostPath.charAt(targetpath.length()-1) == '/');
>             }
>         }
> example 
> targetpath = "/stat/" // where are you
> topmostPath  = "/stat/domain.tld/" // cookie for path

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCLIENT-1043) BasicPathHandler match bug

Posted by "Dmitry Grytsovets (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12981781#action_12981781 ] 

Dmitry Grytsovets commented on HTTPCLIENT-1043:
-----------------------------------------------

In HttpClient page "/d1" can't set cookie for "/d1/d2" but can set for "/"

HttpClient can't login to many sites that uses /d1/d2 cookies after login.

> BasicPathHandler match bug
> --------------------------
>
>                 Key: HTTPCLIENT-1043
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1043
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpCookie
>    Affects Versions: 4.0.1, 4.0.2, 4.0.3, 4.1 Alpha1, 4.1 Alpha2, 4.1 Beta1
>            Reporter: Dmitry Grytsovets
>            Priority: Minor
>
> in BasicPathHandler
>    boolean match = targetpath.startsWith (topmostPath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!topmostPath.endsWith("/")) {
>                 match = (targetpath.charAt(topmostPath.length()) == '/');
>             }
>         }
> must be changed to
>    boolean match = topmostPath.startsWith (targetpath);
>         // if there is a match and these values are not exactly the same we have
>         // to make sure we're not matcing "/foobar" and "/foo"
>         if (match && targetpath.length() != topmostPath.length()) {
>             if (!targetPath.endsWith("/")) {
>                 match = (topmostPath.charAt(targetpath.length()-1) == '/');
>             }
>         }
> example 
> targetpath = "/stat/" // where are you
> topmostPath  = "/stat/domain.tld/" // cookie for path

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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