From 0c30fe98af6c88124cbe234131fae86671f19092 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 5 Oct 2011 09:46:06 +0000 Subject: Handle % in URL without 2 hex digits after. svn path=/trunk/netsurf/; revision=12953 --- utils/nsurl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'utils/nsurl.c') diff --git a/utils/nsurl.c b/utils/nsurl.c index f21f02675..3eb06fc94 100644 --- a/utils/nsurl.c +++ b/utils/nsurl.c @@ -586,9 +586,9 @@ static inline int nsurl__get_ascii_offset(char c1, char c2) /* Use 2nd char as least significant hex digit and sum */ if (isdigit(c2)) offset += c2 - '0'; - else if (c2 >= 'a' && c2 <= 'f')) + else if (c2 >= 'a' && c2 <= 'f') offset += c2 - 'a' + 10; - else if (c2 >= 'A' && c2 <= 'F')) + else if (c2 >= 'A' && c2 <= 'F') offset += c2 - 'A' + 10; else /* Not valid hex */ @@ -681,6 +681,12 @@ static nserror nsurl__create_from_section(const char const *url_s, ascii_offset = nsurl__get_ascii_offset(*(pos + 1), *(pos + 2)); + if (ascii_offset < 0) { + /* % with invalid hex digits. */ + copy_len++; + continue; + } + if (isunreserved(ascii_offset) == false) { /* This character should be escaped after all, * just let it get copied */ -- cgit v1.2.3