Skip to content
GitLab
Explore
Sign in
project
subrequests
Compare revisions
70ef7e44b8c0079258692e00fe98b3ebb33bfda9 to 8.x-2.0-beta3
Commits on Source (1)
fix(JsonPathReplacer): Decode incoming URLs
· 77a90fc5
Mateu Aguiló Bosch
authored
Oct 19, 2017
77a90fc5
Hide whitespace changes
Inline
Side-by-side
src/Normalizer/JsonBlueprintDenormalizer.php
View file @
77a90fc5
...
...
@@ -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
;
}
...
...
tests/src/Unit/Normalizer/JsonBlueprintDenormalizerTest.php
View file @
77a90fc5
...
...
@@ -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
);
}
...
...