From 007a726bee3b0e50e527029bb6dd806a8a3c4b52 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Fri, 20 Jan 2017 01:59:59 +0100 Subject: [PATCH] Fix llUnescapeURL with % in place of the second hex character. When the input was of the form e.g. "%4%40", the second "%" was erroneously starting another quoted character. LSL doesn't behave that way: parsing resumes without starting another quoted character. Disturbingly, the expected result in the corresponding test was wrong. Fixed both the test case and the code to match actual LSL behaviour. --- lslopt/lslbasefuncs.py | 1 + testfuncs.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lslopt/lslbasefuncs.py b/lslopt/lslbasefuncs.py index f419e1e..5bcb1bf 100644 --- a/lslopt/lslbasefuncs.py +++ b/lslopt/lslbasefuncs.py @@ -1757,6 +1757,7 @@ def llUnescapeURL(s): c = s[i] # Second digit if c == u'%': ret += chr(v) + i += 1 continue i += 1 if u'0' <= c <= u'9' or u'A' <= c <= u'F' or u'a' <= c <= u'f': diff --git a/testfuncs.py b/testfuncs.py index aca0aad..8d9ce70 100644 --- a/testfuncs.py +++ b/testfuncs.py @@ -1302,7 +1302,7 @@ def do_tests(): test('llUnescapeURL(u"%")', u'') test('llUnescapeURL(u"%%")', u'') - test('llUnescapeURL(u"%4%252Fabc")', u'\x40\x252Fabc') + test('llUnescapeURL(u"%4%252Fabc")', u'\x40252Fabc') test('llUnescapeURL(u"%%4%252Fabc")', u'\x04\x252Fabc') test('llEscapeURL(llUnescapeURL(u"%.44%25%%2Fa\u2190c"))', u'%044%25%02Fa%E2%86%90c') test('llEscapeURL(llUnescapeURL(u"%.44%25%%2Fa\u2190c%"))', u'%044%25%02Fa%E2%86%90c')