Skip to content

Commit 24c60a5

Browse files
committed
fix uri and urid formats not to convert a space between a plus sign
1 parent 7f0828d commit 24c60a5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

cli/test.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6285,9 +6285,9 @@
62856285
args:
62866286
- '@uri'
62876287
input: |
6288-
[1, {"foo": "<div>&'\"()</div>"}]
6288+
[1, {"foo": "<div>&'\"()+</div>"}]
62896289
expected: |
6290-
"%5B1%2C%7B%22foo%22%3A%22%3Cdiv%3E%26%27%5C%22%28%29%3C%2Fdiv%3E%22%7D%5D"
6290+
"%5B1%2C%7B%22foo%22%3A%22%3Cdiv%3E%26%27%5C%22%28%29%2B%3C%2Fdiv%3E%22%7D%5D"
62916291
62926292
- name: format strings @uri with string interpolation
62936293
args:
@@ -6301,9 +6301,9 @@
63016301
args:
63026302
- '@urid'
63036303
input: |
6304-
"%5B1%2C%7B%22foo%22%3A%22%3Cdiv%3E%26%27%5C%22%28%29%3C%2Fdiv%3E%22%7D%5D"
6304+
"%5B1%2C%7B%22foo%22%3A%22%3Cdiv%3E%26%27%5C%22%28%29%2B%3C%2Fdiv%3E%22%7D%5D"
63056305
expected: |
6306-
"[1,{\"foo\":\"<div>&'\\\"()</div>\"}]"
6306+
"[1,{\"foo\":\"<div>&'\\\"()+</div>\"}]"
63076307
63086308
- name: format strings @urid error
63096309
args:

func.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ func funcToHTML(v any) any {
884884
func funcToURI(v any) any {
885885
switch x := funcToString(v).(type) {
886886
case string:
887-
return url.QueryEscape(x)
887+
return strings.ReplaceAll(url.QueryEscape(x), "+", "%20")
888888
default:
889889
return x
890890
}
@@ -893,7 +893,7 @@ func funcToURI(v any) any {
893893
func funcToURId(v any) any {
894894
switch x := funcToString(v).(type) {
895895
case string:
896-
x, err := url.QueryUnescape(x)
896+
x, err := url.QueryUnescape(strings.ReplaceAll(x, "+", "%2B"))
897897
if err != nil {
898898
return &func0WrapError{"@urid", v, err}
899899
}

0 commit comments

Comments
 (0)