X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=inline;f=ucw%2Furl.c;h=7145af5f764e80b9b9ed60cd223743a76093b008;hb=86b74f27a95b617008575a9088e4c675e9f956d6;hp=8f5073a99721aadef2b1b29526940ee5d58bc8db;hpb=689b60e4c61d300b576fdb7007de51189d2f0f7e;p=libucw.git diff --git a/ucw/url.c b/ucw/url.c index 8f5073a9..7145af5f 100644 --- a/ucw/url.c +++ b/ucw/url.c @@ -7,11 +7,6 @@ * This software may be freely distributed and used according to the terms * of the GNU Lesser General Public License. * - * The URL syntax corresponds to RFC 2396 with several exceptions: - * - * o Escaping of special characters still follows RFC 1738. - * o Interpretation of path parameters follows RFC 1808. - * * XXX: The buffer handling in this module is really horrible, but it works. */ @@ -95,6 +90,12 @@ url_deescape(const char *s, char *d) val = NCC_AND; break; case '#': val = NCC_HASH; break; + case '$': + val = NCC_DOLLAR; break; + case '+': + val = NCC_PLUS; break; + case ',': + val = NCC_COMMA; break; } *d++ = val; s += 3; @@ -133,12 +134,12 @@ url_enescape(const char *s, char *d) { if (d >= end) return URL_ERR_TOO_LONG; - if (Calnum(c) || /* RFC 1738(2.2): Only alphanumerics ... */ - c == '$' || c == '-' || c == '_' || c == '.' || c == '+' || /* ... and several other exceptions ... */ + if (Calnum(c) || /* RFC 2396 (2.1-2.3): Only alphanumerics ... */ + c == '-' || c == '_' || c == '.' || c == '+' || c == '~' || /* ... and several other exceptions ... */ c == '!' || c == '*' || c == '\'' || c == '(' || c == ')' || - c == ',' || c == '/' || c == '?' || c == ':' || c == '@' || /* ... and reserved chars used for reserved purpose */ - c == '=' || c == '&' || c == '#' || c == ';') + c == '=' || c == '&' || c == '#' || c == ';' || + c == '$' || c == '+' || c == ',') *d++ = *s++; else { @@ -318,15 +319,9 @@ relpath_merge(struct url *u, struct url *b) ; goto copy; } - if (a[0] == ';') /* Change parameters */ - { - for(p=o; *p && *p != ';' && *p != '?' && *p != '#'; p++) - ; - goto copy; - } p = NULL; /* Copy original path and find the last slash */ - while (*o && *o != ';' && *o != '?' && *o != '#') + while (*o && *o != '?' && *o != '#') { if (d >= e) return URL_ERR_TOO_LONG; @@ -610,7 +605,7 @@ int main(int argc, char **argv) char buf1[MAX_URL_SIZE], buf2[MAX_URL_SIZE], buf3[MAX_URL_SIZE], buf4[MAX_URL_SIZE]; int err; struct url url, url0; - char *base = "http://mj@www.hell.org/123/sub_dir/index.html;param?query&zzz/subquery#fragment"; + char *base = "http://mj@www.hell.org/123/sub_dir;param/index.html;param?query&zzz/sub;query+#fragment?"; if (argc != 2 && argc != 3) return 1;