Skip to content

Commit

Permalink
Merge pull request #107 from hamishforbes/master
Browse files Browse the repository at this point in the history
Fix for whitespace in esi include tag
  • Loading branch information
pintsized committed Dec 7, 2015
2 parents 6860d38 + 1753447 commit 3f91634
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ledge/esi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ local function esi_fetch_include(include_tag, buffer_size, pre_include_callback,

local src, err = ngx_re_match(
include_tag,
"src=\"(.+)\"[^>*]/>",
[[src="([^"]+)"]],
"oj"
)

Expand Down Expand Up @@ -509,7 +509,7 @@ function _M.get_process_filter(reader, pre_include_callback, recursion_limit)
repeat
local from, to, err = ngx_re_find(
chunk,
"<esi:include src=\"[^\"]+\"\\s*/>",
[[<esi:include\s*src="[^"]+"\s*/>]],
"oj",
ctx
)
Expand Down
30 changes: 30 additions & 0 deletions t/10-esi.t
Original file line number Diff line number Diff line change
Expand Up @@ -1676,3 +1676,33 @@ location /esi_25 {
GET /esi_25_prx
--- raw_response_headers_unlike: Surrogate-Control: content="ESI/1.0\"\r\n
--- response_body: 25a 25b
=== TEST 26: Include tag whitespace
--- http_config eval: $::HttpConfig
--- config
location /esi_26_prx {
rewrite ^(.*)_prx$ $1 break;
content_by_lua '
run()
';
}
location /fragment_1 {
echo "FRAGMENT";
}
location /esi_26 {
default_type text/html;
content_by_lua '
ngx.say("1")
ngx.print("<esi:include src=\\"/fragment_1\\"/>")
ngx.say("2")
ngx.print("<esi:include src=\\"/fragment_1\\" />")
';
}
--- request
GET /esi_26_prx
--- raw_response_headers_unlike: Surrogate-Control: content="ESI/1.0\"\r\n
--- response_body
1
FRAGMENT
2
FRAGMENT

0 comments on commit 3f91634

Please sign in to comment.