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.
This commit is contained in:
Sei Lisa 2017-01-20 01:59:59 +01:00
parent b0f8b7036b
commit 007a726bee
2 changed files with 2 additions and 1 deletions

View file

@ -1757,6 +1757,7 @@ def llUnescapeURL(s):
c = s[i] # Second digit c = s[i] # Second digit
if c == u'%': if c == u'%':
ret += chr(v) ret += chr(v)
i += 1
continue continue
i += 1 i += 1
if u'0' <= c <= u'9' or u'A' <= c <= u'F' or u'a' <= c <= u'f': if u'0' <= c <= u'9' or u'A' <= c <= u'F' or u'a' <= c <= u'f':

View file

@ -1302,7 +1302,7 @@ def do_tests():
test('llUnescapeURL(u"%")', u'') test('llUnescapeURL(u"%")', u'')
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('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')
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')