From 21a435921b62ff8e68610f87bcb669b386d1af41 Mon Sep 17 00:00:00 2001 From: lexx-bright Date: Wed, 27 Nov 2024 08:42:29 +0300 Subject: [PATCH 1/2] Fix the last printable character gets lost if it is preceded by special symbol #135 --- helper/escape/url.go | 2 +- tests/plain/test.toml | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/helper/escape/url.go b/helper/escape/url.go index b50db5f3..25c54c32 100644 --- a/helper/escape/url.go +++ b/helper/escape/url.go @@ -182,7 +182,7 @@ func escapeTo(s string, mode encoding, sb *stringutils.Builder) { if pos == 0 { sb.WriteString(s) return - } else if pos < len(s)-1 { + } else if pos < len(s) { sb.WriteString(s[pos:]) } } diff --git a/tests/plain/test.toml b/tests/plain/test.toml index 3accfa47..f8bdcd41 100644 --- a/tests/plain/test.toml +++ b/tests/plain/test.toml @@ -89,7 +89,7 @@ input = [ "cpu.loadavg;env=test;host=host1 2.1 1625478240", "test.host1.cpu.loadavg 9.4 1625478300", "cpu.loadavg;host=host1;env=test 1.3 1625478360", - "spec_symbols;minus=-;plus=+;percent=%;underscore=_;colon=:;hash=#;forward=/ 5.1 1625478360", + "spec_symbols;minus=-;plus=+;percent=%;underscore=_;colon=:;hash=#;forward=/a 5.1 1625478360", "non-ascii.иван;tagged=true 1.2 1625478240" ] @@ -155,23 +155,23 @@ output = [ ] # Tests for issue #116 -# spec_symbols;minus=-;plus=+;percent=%;underscore=_;colon=:;hash=#;forward=/ 5.1 1625478360 +# spec_symbols;minus=-;plus=+;percent=%;underscore=_;colon=:;hash=#;forward/0=/0 5.1 1625478360 [[test.verify]] query = "SELECT Date, Tag1, Path, arraySort(Tags) as Tags FROM graphite_tags WHERE Path LIKE 'spec_symbols?%' ORDER BY Date, Tag1, Path" output = [ - "2021-07-05 __name__=spec_symbols spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward=/','hash=#','minus=-','percent=%','plus=+','underscore=_']", - "2021-07-05 colon=: spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward=/','hash=#','minus=-','percent=%','plus=+','underscore=_']", - "2021-07-05 forward=/ spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward=/','hash=#','minus=-','percent=%','plus=+','underscore=_']", - "2021-07-05 hash=# spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward=/','hash=#','minus=-','percent=%','plus=+','underscore=_']", - "2021-07-05 minus=- spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward=/','hash=#','minus=-','percent=%','plus=+','underscore=_']", - "2021-07-05 percent=% spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward=/','hash=#','minus=-','percent=%','plus=+','underscore=_']", - "2021-07-05 plus=+ spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward=/','hash=#','minus=-','percent=%','plus=+','underscore=_']", - "2021-07-05 underscore=_ spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward=/','hash=#','minus=-','percent=%','plus=+','underscore=_']" + "2021-07-05 __name__=spec_symbols spec_symbols?colon=%3A&forward%2F0=%2F0&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward/0=/0','hash=#','minus=-','percent=%','plus=+','underscore=_']", + "2021-07-05 colon=: spec_symbols?colon=%3A&forward%2F0=%2F0&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward/0=/0','hash=#','minus=-','percent=%','plus=+','underscore=_']", + "2021-07-05 forward/0=/0 spec_symbols?colon=%3A&forward%2F0=%2F0&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward/0=/0','hash=#','minus=-','percent=%','plus=+','underscore=_']", + "2021-07-05 hash=# spec_symbols?colon=%3A&forward%2F0=%2F0&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward/0=/0','hash=#','minus=-','percent=%','plus=+','underscore=_']", + "2021-07-05 minus=- spec_symbols?colon=%3A&forward%2F0=%2F0&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward/0=/0','hash=#','minus=-','percent=%','plus=+','underscore=_']", + "2021-07-05 percent=% spec_symbols?colon=%3A&forward%2F0=%2F0&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward/0=/0','hash=#','minus=-','percent=%','plus=+','underscore=_']", + "2021-07-05 plus=+ spec_symbols?colon=%3A&forward%2F0=%2F0&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward/0=/0','hash=#','minus=-','percent=%','plus=+','underscore=_']", + "2021-07-05 underscore=_ spec_symbols?colon=%3A&forward%2F0=%2F0&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ ['__name__=spec_symbols','colon=:','forward/0=/0','hash=#','minus=-','percent=%','plus=+','underscore=_']" ] [[test.verify]] query = "SELECT Path, Value, Time, Date, Timestamp FROM graphite WHERE Path LIKE 'spec_symbols?%' ORDER BY Time, Path" output = [ - "spec_symbols?colon=%3A&forward=%2F&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ 5.1 1625478360 2021-07-05 0" + "spec_symbols?colon=%3A&forward%2F0=%2F0&hash=%23&minus=-&percent=%25&plus=%2B&underscore=_ 5.1 1625478360 2021-07-05 0" ] # Tests for non-ASCII symbols in path From 94a6309643cd7ac2ba07c599c3ed17622b34295b Mon Sep 17 00:00:00 2001 From: lexx-bright Date: Wed, 27 Nov 2024 13:04:00 +0300 Subject: [PATCH 2/2] Fix typo --- tests/plain/test.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/plain/test.toml b/tests/plain/test.toml index f8bdcd41..0af5d7f2 100644 --- a/tests/plain/test.toml +++ b/tests/plain/test.toml @@ -89,7 +89,7 @@ input = [ "cpu.loadavg;env=test;host=host1 2.1 1625478240", "test.host1.cpu.loadavg 9.4 1625478300", "cpu.loadavg;host=host1;env=test 1.3 1625478360", - "spec_symbols;minus=-;plus=+;percent=%;underscore=_;colon=:;hash=#;forward=/a 5.1 1625478360", + "spec_symbols;minus=-;plus=+;percent=%;underscore=_;colon=:;hash=#;forward/0=/0 5.1 1625478360", "non-ascii.иван;tagged=true 1.2 1625478240" ] @@ -154,7 +154,7 @@ output = [ "cpu.loadavg?env=test&host=host1 1.3 1625478360 2021-07-05 0", ] -# Tests for issue #116 +# Tests for issues: #116 #135 # spec_symbols;minus=-;plus=+;percent=%;underscore=_;colon=:;hash=#;forward/0=/0 5.1 1625478360 [[test.verify]] query = "SELECT Date, Tag1, Path, arraySort(Tags) as Tags FROM graphite_tags WHERE Path LIKE 'spec_symbols?%' ORDER BY Date, Tag1, Path"