mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-26 16:29:36 +03:00
Fix upper case hex and return -1 for invalid hex.
svn path=/trunk/netsurf/; revision=12952
This commit is contained in:
parent
c18c9b5511
commit
20c70fcb90
@ -564,7 +564,7 @@ static size_t nsurl__get_longest_section(struct url_markers *m)
|
||||
*
|
||||
* \param c1 most significant hex digit
|
||||
* \param c2 least significant hex digit
|
||||
* \return the total value of the two digit hex number
|
||||
* \return the total value of the two digit hex number, or -ve if input not hex
|
||||
*
|
||||
* For unescaping url encoded characters.
|
||||
*/
|
||||
@ -575,20 +575,24 @@ static inline int nsurl__get_ascii_offset(char c1, char c2)
|
||||
/* Use 1st char as most significant hex digit */
|
||||
if (isdigit(c1))
|
||||
offset = 16 * (c1 - '0');
|
||||
else if ((c1 >= 'a' && c1 <= 'f') || (c1 >= 'A' && c1 <= 'F'))
|
||||
else if (c1 >= 'a' && c1 <= 'f')
|
||||
offset = 16 * (c1 - 'a' + 10);
|
||||
else if (c1 >= 'A' && c1 <= 'F')
|
||||
offset = 16 * (c1 - 'A' + 10);
|
||||
else
|
||||
/* TODO: return something special to indicate error? */
|
||||
return 0;
|
||||
/* Not valid hex */
|
||||
return -1;
|
||||
|
||||
/* Use 2nd char as least significant hex digit and sum */
|
||||
if (isdigit(c2))
|
||||
offset += c2 - '0';
|
||||
else if ((c2 >= 'a' && c2 <= 'f') || (c2 >= 'A' && c2 <= 'F'))
|
||||
else if (c2 >= 'a' && c2 <= 'f'))
|
||||
offset += c2 - 'a' + 10;
|
||||
else if (c2 >= 'A' && c2 <= 'F'))
|
||||
offset += c2 - 'A' + 10;
|
||||
else
|
||||
/* TODO: return something special to indicate error? */
|
||||
return 0;
|
||||
/* Not valid hex */
|
||||
return -1;
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user