mirror of
https://github.com/dlang/phobos.git
synced 2025-05-02 16:10:45 +03:00
Fix of Issue 11338
- URIerror renamed to URIexception - URIexception class inherits from Exception
This commit is contained in:
parent
693ccb171d
commit
1fd19c2366
1 changed files with 18 additions and 18 deletions
36
std/uri.d
36
std/uri.d
|
@ -36,7 +36,7 @@ private import std.c.stdlib;
|
||||||
private import std.utf;
|
private import std.utf;
|
||||||
import std.exception;
|
import std.exception;
|
||||||
|
|
||||||
class URIerror : Error
|
class URIexception : Exception
|
||||||
{
|
{
|
||||||
this()
|
this()
|
||||||
{
|
{
|
||||||
|
@ -116,7 +116,7 @@ private string URI_Encode(dstring string, uint unescapedSet)
|
||||||
{
|
{
|
||||||
R2 = cast(char *)alloca(Rsize * char.sizeof);
|
R2 = cast(char *)alloca(Rsize * char.sizeof);
|
||||||
if (!R2)
|
if (!R2)
|
||||||
goto LthrowURIerror;
|
goto LthrowURIexception;
|
||||||
}
|
}
|
||||||
R2[0..Rlen] = R[0..Rlen];
|
R2[0..Rlen] = R[0..Rlen];
|
||||||
R = R2;
|
R = R2;
|
||||||
|
@ -181,7 +181,7 @@ private string URI_Encode(dstring string, uint unescapedSet)
|
||||||
+/
|
+/
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
goto LthrowURIerror; // undefined UTF-32 code
|
goto LthrowURIexception; // undefined UTF-32 code
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Rlen + L * 3 > Rsize)
|
if (Rlen + L * 3 > Rsize)
|
||||||
|
@ -196,7 +196,7 @@ private string URI_Encode(dstring string, uint unescapedSet)
|
||||||
{
|
{
|
||||||
R2 = cast(char *)alloca(Rsize * char.sizeof);
|
R2 = cast(char *)alloca(Rsize * char.sizeof);
|
||||||
if (!R2)
|
if (!R2)
|
||||||
goto LthrowURIerror;
|
goto LthrowURIexception;
|
||||||
}
|
}
|
||||||
R2[0..Rlen] = R[0..Rlen];
|
R2[0..Rlen] = R[0..Rlen];
|
||||||
R = R2;
|
R = R2;
|
||||||
|
@ -215,8 +215,8 @@ private string URI_Encode(dstring string, uint unescapedSet)
|
||||||
|
|
||||||
return R[0..Rlen].idup;
|
return R[0..Rlen].idup;
|
||||||
|
|
||||||
LthrowURIerror:
|
LthrowURIexception:
|
||||||
throw new URIerror();
|
throw new URIexception();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint ascii2hex(dchar c)
|
uint ascii2hex(dchar c)
|
||||||
|
@ -249,7 +249,7 @@ private dstring URI_Decode(string string, uint reservedSet)
|
||||||
{
|
{
|
||||||
R = cast(dchar *)alloca(Rsize * dchar.sizeof);
|
R = cast(dchar *)alloca(Rsize * dchar.sizeof);
|
||||||
if (!R)
|
if (!R)
|
||||||
goto LthrowURIerror;
|
goto LthrowURIexception;
|
||||||
}
|
}
|
||||||
Rlen = 0;
|
Rlen = 0;
|
||||||
|
|
||||||
|
@ -267,9 +267,9 @@ private dstring URI_Decode(string string, uint reservedSet)
|
||||||
}
|
}
|
||||||
start = k;
|
start = k;
|
||||||
if (k + 2 >= len)
|
if (k + 2 >= len)
|
||||||
goto LthrowURIerror;
|
goto LthrowURIexception;
|
||||||
if (!isHexDigit(s[k + 1]) || !isHexDigit(s[k + 2]))
|
if (!isHexDigit(s[k + 1]) || !isHexDigit(s[k + 2]))
|
||||||
goto LthrowURIerror;
|
goto LthrowURIexception;
|
||||||
B = cast(char)((ascii2hex(s[k + 1]) << 4) + ascii2hex(s[k + 2]));
|
B = cast(char)((ascii2hex(s[k + 1]) << 4) + ascii2hex(s[k + 2]));
|
||||||
k += 2;
|
k += 2;
|
||||||
if ((B & 0x80) == 0)
|
if ((B & 0x80) == 0)
|
||||||
|
@ -283,11 +283,11 @@ private dstring URI_Decode(string string, uint reservedSet)
|
||||||
for (n = 1; ; n++)
|
for (n = 1; ; n++)
|
||||||
{
|
{
|
||||||
if (n > 4)
|
if (n > 4)
|
||||||
goto LthrowURIerror;
|
goto LthrowURIexception;
|
||||||
if (((B << n) & 0x80) == 0)
|
if (((B << n) & 0x80) == 0)
|
||||||
{
|
{
|
||||||
if (n == 1)
|
if (n == 1)
|
||||||
goto LthrowURIerror;
|
goto LthrowURIexception;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,22 +296,22 @@ private dstring URI_Decode(string string, uint reservedSet)
|
||||||
V = B & ((1 << (7 - n)) - 1); // (!!!)
|
V = B & ((1 << (7 - n)) - 1); // (!!!)
|
||||||
|
|
||||||
if (k + (3 * (n - 1)) >= len)
|
if (k + (3 * (n - 1)) >= len)
|
||||||
goto LthrowURIerror;
|
goto LthrowURIexception;
|
||||||
for (j = 1; j != n; j++)
|
for (j = 1; j != n; j++)
|
||||||
{
|
{
|
||||||
k++;
|
k++;
|
||||||
if (s[k] != '%')
|
if (s[k] != '%')
|
||||||
goto LthrowURIerror;
|
goto LthrowURIexception;
|
||||||
if (!isHexDigit(s[k + 1]) || !isHexDigit(s[k + 2]))
|
if (!isHexDigit(s[k + 1]) || !isHexDigit(s[k + 2]))
|
||||||
goto LthrowURIerror;
|
goto LthrowURIexception;
|
||||||
B = cast(char)((ascii2hex(s[k + 1]) << 4) + ascii2hex(s[k + 2]));
|
B = cast(char)((ascii2hex(s[k + 1]) << 4) + ascii2hex(s[k + 2]));
|
||||||
if ((B & 0xC0) != 0x80)
|
if ((B & 0xC0) != 0x80)
|
||||||
goto LthrowURIerror;
|
goto LthrowURIexception;
|
||||||
k += 2;
|
k += 2;
|
||||||
V = (V << 6) | (B & 0x3F);
|
V = (V << 6) | (B & 0x3F);
|
||||||
}
|
}
|
||||||
if (V > 0x10FFFF)
|
if (V > 0x10FFFF)
|
||||||
goto LthrowURIerror;
|
goto LthrowURIexception;
|
||||||
C = V;
|
C = V;
|
||||||
}
|
}
|
||||||
if (C < uri_flags.length && uri_flags[C] & reservedSet)
|
if (C < uri_flags.length && uri_flags[C] & reservedSet)
|
||||||
|
@ -334,8 +334,8 @@ private dstring URI_Decode(string string, uint reservedSet)
|
||||||
return R[0..Rlen].idup;
|
return R[0..Rlen].idup;
|
||||||
|
|
||||||
|
|
||||||
LthrowURIerror:
|
LthrowURIexception:
|
||||||
throw new URIerror();
|
throw new URIexception();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************
|
/*************************************
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue