fix(JsonPathReplacer): Decode incoming URLs

parent 70ef7e44
......@@ -122,6 +122,15 @@ class JsonBlueprintDenormalizer implements DenormalizerInterface, SerializerAwar
$raw_item['waitFor'] = !empty($raw_item['waitFor']) ? $raw_item['waitFor'] : ['<ROOT>'];
$raw_item['_resolved'] = FALSE;
// Detect if there is an encoded token. If so, then decode the URI.
if (
!empty($raw_item['uri']) &&
strpos($raw_item['uri'], '%7B%7B') !== FALSE &&
strpos($raw_item['uri'], '%7D%7D') !== FALSE
) {
$raw_item['uri'] = urldecode($raw_item['uri']);
}
return $raw_item;
}
......
......@@ -59,7 +59,7 @@ class JsonBlueprintDenormalizerTest extends UnitTestCase {
'waitFor' => ['foo'],
];
$subrequests[] = [
'uri' => 'lorem',
'uri' => 'lorem%3F%7B%7Bipsum%7D%7D', // lorem?{{ipsum}}
'action' => 'create',
'requestId' => 'oof',
'body' => '"bar"',
......@@ -70,7 +70,16 @@ class JsonBlueprintDenormalizerTest extends UnitTestCase {
$tree->stack([new Subrequest(['waitFor' => ['<ROOT>'], '_resolved' => FALSE, 'body' => 'bar'] + $subrequests[0])]);
$tree->stack([
new Subrequest(['headers' => [], '_resolved' => FALSE, 'body' => []] + $subrequests[1]),
new Subrequest(['headers' => [], '_resolved' => FALSE, 'body' => 'bar'] + $subrequests[2])
// Make sure the URL is decoded so we can perform apply regular
// expressions to it.
new Subrequest(
[
'headers' => [],
'_resolved' => FALSE,
'body' => 'bar',
'uri' => 'lorem?{{ipsum}}'
] + $subrequests[2]
)
]);
$this->assertEquals($tree, $actual);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment