Return-Path: Mailing-List: contact commons-httpclient-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-httpclient-dev@jakarta.apache.org Received: (qmail 3239 invoked by uid 98); 24 Jan 2003 09:51:37 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Received: (qmail 3200 invoked from network); 24 Jan 2003 09:51:35 -0000 Received: from unknown (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 24 Jan 2003 09:51:35 -0000 Received: (qmail 99828 invoked by uid 500); 24 Jan 2003 09:49:59 -0000 Received: (qmail 99819 invoked from network); 24 Jan 2003 09:49:59 -0000 Received: from unknown (HELO www.newknow.com) (212.163.50.51) by 208.185.179.12.available.above.net with SMTP; 24 Jan 2003 09:49:59 -0000 X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_001_01C2C38D.F8A35388" Subject: Bug in setRawPath method of URI class Date: Fri, 24 Jan 2003 10:50:04 +0100 Message-ID: X-MS-Has-Attach: yes X-MS-TNEF-Correlator: Thread-Topic: Bug in setRawPath method of URI class Thread-Index: AcLDjfiqKquxABF8QzmdE4QMApkIQw== From: =?iso-8859-1?Q?Armando_Ant=F3n?= To: "Commons HttpClient Project (E-mail)" X-Spam-Rating: 208.185.179.12.available.above.net 1.6.2 0/1000/N ------_=_NextPart_001_01C2C38D.F8A35388 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi! i think there is a bug in the setRawPath method when working with = relative paths that does not start with the '/' character i will write first the code and after that i will try to explain why = there is a bug :) class URI (lines 2692-2701) } else if (_is_rel_path) { int at =3D indexFirstOf(escapedPath, '/'); if (at =3D=3D 0) throw new URIException(URIException.PARSING, "incorrect = path"); if (at > 0 && !validate(escapedPath, 0, at, rel_segment) || at < 0 && !validate(escapedPath, 0, -1, abs_path)) throw new URIException(URIException.ESCAPING, "escaped relative path not valid"); _path =3D escapedPath; } when the uri is relative, first it checks if the escapedPath starts with = the '/' character (if true then the path is not relative and an = exception is thrown) after that, there is a double check: 1. there is a '/' character and the escapedpath(from the first character = to the first occurrence of the '/' character) is valid (using the = rel_segment BitSet) 2. there is not a '/' character and the escapedpath (all the characters) = is valid (using the abs_path BitSet) the problem is in the first check because the substring validated ends = with the '/' character and the rel_segment BitSet does not allow that = character so an exception is thrown i really does not understand that double check and i have changed it to: } else if (_is_rel_path) { int at =3D indexFirstOf(escapedPath, '/'); if (at =3D=3D 0) throw new URIException(URIException.PARSING, "incorrect = path"); if (!validate(escapedPath, 0, -1, abs_path)) throw new URIException(URIException.ESCAPING, "escaped relative path not valid"); _path =3D escapedPath; } =20 To test this bug you can execute this simple class and an exception will = occur import org.apache.commons.httpclient.URI; public class TestSetRawPath { public static void main(String[] args) throws Exception { char[] _uri =3D "dir/doc.html".toCharArray(); URI uri =3D new URI(_uri); } } Hope it helps, Thank you for your great effort, Armando <>=20 ------_=_NextPart_001_01C2C38D.F8A35388 Content-Type: application/octet-stream; name="URI_v1.22.diff" Content-Transfer-Encoding: base64 Content-Description: URI_v1.22.diff Content-Disposition: attachment; filename="URI_v1.22.diff" SW5kZXg6IFVSSS5qYXZhDQo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09DQpSQ1MgZmlsZTogL2hvbWUvY3ZzcHVibGljL2ph a2FydGEtY29tbW9ucy9odHRwY2xpZW50L3NyYy9qYXZhL29yZy9hcGFjaGUvY29tbW9ucy9odHRw Y2xpZW50L1VSSS5qYXZhLHYNCnJldHJpZXZpbmcgcmV2aXNpb24gMS4yMg0KZGlmZiAtcjEuMjIg VVJJLmphdmENCjI2OTYsMjY5N2MyNjk2DQo8ICAgICAgICAgICAgIGlmIChhdCA+IDAgJiYgIXZh bGlkYXRlKGVzY2FwZWRQYXRoLCAwLCBhdCwgcmVsX3NlZ21lbnQpIHx8DQo8ICAgICAgICAgICAg ICAgICAgICAgYXQgPCAwICYmICF2YWxpZGF0ZShlc2NhcGVkUGF0aCwgMCwgLTEsIGFic19wYXRo KSkNCi0tLQ0KPiAgICAgICAgICAgICBpZiAoIXZhbGlkYXRlKGVzY2FwZWRQYXRoLCAwLCAtMSwg YWJzX3BhdGgpKQ0K ------_=_NextPart_001_01C2C38D.F8A35388--