[Issue 1937] New: std.uri.decode throws wrong exception
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Mar 24 15:40:08 PDT 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1937
Summary: std.uri.decode throws wrong exception
Product: D
Version: 1.028
Platform: PC
OS/Version: Windows
Status: NEW
Keywords: diagnostic
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: bugzilla at digitalmars.com
ReportedBy: stefan.zipproth at web.de
If the parameter of std.uri.decode contains %E4, which is a German umlaut รค,
the exception "URI error" is thrown. This is wrong behaviour, as an URI may
contains umlauts. Here's my C implementation which does the job:
void decode(char *src, char *last, char *dest)
{
for (; src != last; src++, dest++)
if (*src == '+')
*dest = ' ';
else if (*src == '%')
{
int code;
if (sscanf(src+1, "%2x", &code) != 1) code = '?';
*dest = code;
src +=2;
}
else
*dest = *src;
*dest = 0;
}
To my understanding, it's nothing else than a hex code to byte conversion, so
there should be no reason to forbid certain codes and throw exceptions. Also
reading the documentation I expected that at least std.uri.decodeComponent is a
straightforward implementation, but it also throws exceptions.
--
More information about the Digitalmars-d-bugs
mailing list