Merge pull request #257 from Orange-OpenSource/feature/escape-hash

Escape Hash(#) in hurl string value
This commit is contained in:
Fabrice Reix 2021-09-10 08:58:50 +02:00 committed by GitHub
commit abea6a867f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 3 deletions

View File

@ -1 +1 @@
<div class="hurl-file"><div class="hurl-entry"><div class="request"><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/default-headers</span></span></div><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/default-headers</span></span></div><span class="line"><span class="string">User-Agent</span><span>:</span> <span class="string">hurl/1.0</span></span><span class="line"><span class="string">Host</span><span>:</span> <span class="string">localhost:8000</span> <span class="comment"># comment</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/default-headers</span></span></div><span class="line"><span class="string">User-Agent</span><span>:</span> <span class="string">hurl/1.0</span></span><span class="line"><span class="string">Host</span><span>:</span> <span class="string">localhost:8000</span> <span class="comment"># comment</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/custom-headers</span></span></div><span class="line"><span class="string">Fruit</span><span>:</span> <span class="string">Raspberry</span></span><span class="line"><span class="string">Fruit</span><span>:</span> <span class="string">Apple</span></span><span class="line"><span class="string">Fruit</span><span>:</span> <span class="string">Banana</span></span><span class="line"><span class="string">Fruit</span><span>:</span> <span class="string">Grape</span></span><span class="line"><span class="string">Color</span><span>:</span> <span class="string">Green</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/custom-headers-utf8</span></span></div><span class="line"><span class="string">Beverage</span><span>:</span> <span class="string">café</span> <span class="comment"># send the utf8 string - expected to be decoded as ascii in the server side</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/custom-headers-quote</span></span></div><span class="line"><span class="string">Header1</span><span>:</span> <span class="string">'</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/response-headers</span></span></div><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span><span class="line"><span class="string">Beverage</span><span>:</span> <span class="string">cafe</span> <span class="comment"># TBC send utf8</span></span></div></div></div>
<div class="hurl-file"><div class="hurl-entry"><div class="request"><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/default-headers</span></span></div><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/default-headers</span></span></div><span class="line"><span class="string">User-Agent</span><span>:</span> <span class="string">hurl/1.0</span></span><span class="line"><span class="string">Host</span><span>:</span> <span class="string">localhost:8000</span> <span class="comment"># comment</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/default-headers</span></span></div><span class="line"><span class="string">User-Agent</span><span>:</span> <span class="string">hurl/1.0</span></span><span class="line"><span class="string">Host</span><span>:</span> <span class="string">localhost:8000</span> <span class="comment"># comment</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/custom-headers</span></span></div><span class="line"><span class="string">Fruit</span><span>:</span> <span class="string">Raspberry</span></span><span class="line"><span class="string">Fruit</span><span>:</span> <span class="string">Apple</span></span><span class="line"><span class="string">Fruit</span><span>:</span> <span class="string">Banana</span></span><span class="line"><span class="string">Fruit</span><span>:</span> <span class="string">Grape</span></span><span class="line"><span class="string">Color</span><span>:</span> <span class="string">Green</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/custom-headers-utf8</span></span></div><span class="line"><span class="string">Beverage</span><span>:</span> <span class="string">café</span> <span class="comment"># send the utf8 string - expected to be decoded as ascii in the server side</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/custom-headers-value</span></span></div><span class="line"><span class="string">Id</span><span>:</span> <span class="string">#123</span> <span class="comment"># send a hash in the value</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/custom-headers-quote</span></span></div><span class="line"><span class="string">Header1</span><span>:</span> <span class="string">'</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/response-headers</span></span></div><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span><span class="line"><span class="string">Beverage</span><span>:</span> <span class="string">cafe</span> <span class="comment"># TBC send utf8</span></span></div></div></div>

View File

@ -24,6 +24,10 @@ GET http://localhost:8000/custom-headers-utf8
Beverage: café # send the utf8 string - expected to be decoded as ascii in the server side
HTTP/1.0 200
GET http://localhost:8000/custom-headers-value
Id: \#123 # send a hash in the value
HTTP/1.0 200
GET http://localhost:8000/custom-headers-quote
Header1: '
HTTP/1.0 200

View File

@ -1 +1 @@
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/default-headers"},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/default-headers","headers":[{"name":"User-Agent","value":"hurl/1.0"},{"name":"Host","value":"localhost:8000"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/default-headers","headers":[{"name":"User-Agent","value":"hurl/1.0"},{"name":"Host","value":"localhost:8000"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/custom-headers","headers":[{"name":"Fruit","value":"Raspberry"},{"name":"Fruit","value":"Apple"},{"name":"Fruit","value":"Banana"},{"name":"Fruit","value":"Grape"},{"name":"Color","value":"Green"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/custom-headers-utf8","headers":[{"name":"Beverage","value":"café"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/custom-headers-quote","headers":[{"name":"Header1","value":"'"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/response-headers"},"response":{"version":"HTTP/1.0","status":200,"headers":[{"name":"Beverage","value":"cafe"}]}}]}
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/default-headers"},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/default-headers","headers":[{"name":"User-Agent","value":"hurl/1.0"},{"name":"Host","value":"localhost:8000"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/default-headers","headers":[{"name":"User-Agent","value":"hurl/1.0"},{"name":"Host","value":"localhost:8000"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/custom-headers","headers":[{"name":"Fruit","value":"Raspberry"},{"name":"Fruit","value":"Apple"},{"name":"Fruit","value":"Banana"},{"name":"Fruit","value":"Grape"},{"name":"Color","value":"Green"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/custom-headers-utf8","headers":[{"name":"Beverage","value":"café"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/custom-headers-value","headers":[{"name":"Id","value":"#123"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/custom-headers-quote","headers":[{"name":"Header1","value":"'"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/response-headers"},"response":{"version":"HTTP/1.0","status":200,"headers":[{"name":"Beverage","value":"cafe"}]}}]}

View File

@ -24,6 +24,10 @@ def custom_headers_utf8():
assert request.headers['Beverage'] == '\x63\x61\x66\xc3\xa9'
return ''
@app.route("/custom-headers-value")
def custom_headers_value():
assert request.headers['Id'] == '#123'
return ''
@app.route("/custom-headers-quote")
def custom_headers_quotes():

View File

@ -229,7 +229,7 @@ fn escape_char(reader: &mut Reader) -> ParseResult<'static, char> {
try_literal("\\", reader)?;
let start = reader.state.clone();
match reader.read() {
// Some('#') => Ok('#'),
Some('#') => Ok('#'),
Some('"') => Ok('"'),
Some('\\') => Ok('\\'),
Some('/') => Ok('/'),