chunked: fix escape of space
the code was copied from the composefs C version:
if (noescape_space)
hex_escape = !isprint(c);
else
hex_escape = !isgraph(c);
but unicode.IsGraphic() seems to behave differently and includes the
space:
isgraph(' ') -> 0
unicode.IsGraphic(' ') -> true
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
(cherry picked from commit 839beda40e)
This commit is contained in:
parent
8c3e6d7e3e
commit
c8291eee40
|
|
@ -52,7 +52,7 @@ func escaped(val string, escape int) string {
|
||||||
if noescapeSpace {
|
if noescapeSpace {
|
||||||
hexEscape = !unicode.IsPrint(rune(c))
|
hexEscape = !unicode.IsPrint(rune(c))
|
||||||
} else {
|
} else {
|
||||||
hexEscape = !unicode.IsGraphic(rune(c))
|
hexEscape = !unicode.IsPrint(rune(c)) || unicode.IsSpace(rune(c))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ func TestEscaped(t *testing.T) {
|
||||||
escape int
|
escape int
|
||||||
want string
|
want string
|
||||||
}{
|
}{
|
||||||
{"Hello, World!", 0, "Hello, World!"},
|
|
||||||
{"12345", 0, "12345"},
|
{"12345", 0, "12345"},
|
||||||
{"", 0, ""},
|
{"", 0, ""},
|
||||||
{"\n", 0, "\\n"},
|
{"\n", 0, "\\n"},
|
||||||
|
|
@ -25,9 +24,12 @@ func TestEscaped(t *testing.T) {
|
||||||
{"foo=bar", ESCAPE_EQUAL, "foo\\x3dbar"},
|
{"foo=bar", ESCAPE_EQUAL, "foo\\x3dbar"},
|
||||||
{"-", ESCAPE_LONE_DASH, "\\x2d"},
|
{"-", ESCAPE_LONE_DASH, "\\x2d"},
|
||||||
{"\n", NOESCAPE_SPACE, "\\n"},
|
{"\n", NOESCAPE_SPACE, "\\n"},
|
||||||
|
{" ", 0, "\\x20"},
|
||||||
{" ", NOESCAPE_SPACE, " "},
|
{" ", NOESCAPE_SPACE, " "},
|
||||||
{"\t", NOESCAPE_SPACE, "\\t"},
|
{"\t", NOESCAPE_SPACE, "\\t"},
|
||||||
{"\n\t", NOESCAPE_SPACE, "\\n\\t"},
|
{"\n\t", NOESCAPE_SPACE, "\\n\\t"},
|
||||||
|
{"Hello World!", 0, "Hello\\x20World!"},
|
||||||
|
{"Hello World!", NOESCAPE_SPACE, "Hello World!"},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue