mirror of https://github.com/adamdruppe/arsd.git
stuff
This commit is contained in:
parent
f8ce62c773
commit
5db0da2abb
2
http2.d
2
http2.d
|
@ -756,7 +756,7 @@ class HttpRequest {
|
||||||
if(requestParameters.userAgent.length)
|
if(requestParameters.userAgent.length)
|
||||||
headers ~= "User-Agent: "~requestParameters.userAgent~"\r\n";
|
headers ~= "User-Agent: "~requestParameters.userAgent~"\r\n";
|
||||||
if(requestParameters.authorization.length)
|
if(requestParameters.authorization.length)
|
||||||
headers ~= "User-Agent: "~requestParameters.authorization~"\r\n";
|
headers ~= "Authorization: "~requestParameters.authorization~"\r\n";
|
||||||
if(requestParameters.bodyData.length)
|
if(requestParameters.bodyData.length)
|
||||||
headers ~= "Content-Length: "~to!string(requestParameters.bodyData.length)~"\r\n";
|
headers ~= "Content-Length: "~to!string(requestParameters.bodyData.length)~"\r\n";
|
||||||
|
|
||||||
|
|
26
script.d
26
script.d
|
@ -352,17 +352,39 @@ class TokenStream(TextStream) {
|
||||||
token.type = ScriptToken.Type.string;
|
token.type = ScriptToken.Type.string;
|
||||||
int pos = 1; // skip the opening "
|
int pos = 1; // skip the opening "
|
||||||
bool escaped = false;
|
bool escaped = false;
|
||||||
|
bool mustCopy = false;
|
||||||
// FIXME: escaping doesn't do the right thing lol. we should slice if we can, copy if not
|
// FIXME: escaping doesn't do the right thing lol. we should slice if we can, copy if not
|
||||||
while(pos < text.length && (escaped || text[pos] != '"')) {
|
while(pos < text.length && (escaped || text[pos] != '"')) {
|
||||||
if(escaped)
|
if(escaped) {
|
||||||
|
mustCopy = true;
|
||||||
escaped = false;
|
escaped = false;
|
||||||
else
|
} else
|
||||||
if(text[pos] == '\\')
|
if(text[pos] == '\\')
|
||||||
escaped = true;
|
escaped = true;
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(mustCopy) {
|
||||||
|
// there must be something escaped in there, so we need
|
||||||
|
// to copy it and properly handle those cases
|
||||||
|
string copy;
|
||||||
|
copy.reserve(pos);
|
||||||
|
|
||||||
|
escaped = false;
|
||||||
|
foreach(dchar ch; text[1 .. pos]) {
|
||||||
|
if(escaped)
|
||||||
|
escaped = false;
|
||||||
|
else if(ch == '\\') {
|
||||||
|
escaped = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
copy ~= ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
token.str = copy;
|
||||||
|
} else {
|
||||||
token.str = text[1 .. pos];
|
token.str = text[1 .. pos];
|
||||||
|
}
|
||||||
advance(pos + 1); // skip the closing " too
|
advance(pos + 1); // skip the closing " too
|
||||||
} else {
|
} else {
|
||||||
// let's check all symbols
|
// let's check all symbols
|
||||||
|
|
Loading…
Reference in New Issue