JSVar: oops
This commit is contained in:
parent
d5a43991b6
commit
99e797410d
1 changed files with 7 additions and 5 deletions
|
|
@ -28,7 +28,7 @@ __all__ = ['JSPayload', 'JSVar']
|
||||||
|
|
||||||
|
|
||||||
def _quoted(q):
|
def _quoted(q):
|
||||||
return r'{0}(?:[^{0}]|\{0})*{0}'.format(q)
|
return r'(?<!\\){0}(?:\\{0}|[^{0}])*{0}'.format(q)
|
||||||
|
|
||||||
|
|
||||||
class JSPayload(Filter):
|
class JSPayload(Filter):
|
||||||
|
|
@ -68,13 +68,15 @@ class JSVar(Regexp):
|
||||||
It only understands literal values, but should parse them well. Values
|
It only understands literal values, but should parse them well. Values
|
||||||
are converted in python values, quotes and slashes in strings are stripped.
|
are converted in python values, quotes and slashes in strings are stripped.
|
||||||
|
|
||||||
>>> JSVar(var='test').filter("var test = .1")
|
>>> JSVar(var='test').filter("var test = .1;\nsomecode()")
|
||||||
0.1
|
0.1
|
||||||
>>> JSVar(var='test').filter("test = 42")
|
>>> JSVar(var='test').filter("test = 42;\nsomecode()")
|
||||||
42
|
42
|
||||||
>>> JSVar(var='test').filter('test = "Some \\"string\\" value"')
|
>>> JSVar(var='test').filter("test = 'Some \\'string\\' value, isn\\'t it ?';\nsomecode()")
|
||||||
|
"Some 'string' value, isn't it ?"
|
||||||
|
>>> JSVar(var='test').filter('test = "Some \\"string\\" value";\nsomecode()')
|
||||||
'Some "string" value'
|
'Some "string" value'
|
||||||
>>> JSVar(var='test').filter("var test = false")
|
>>> JSVar(var='test').filter("var test = false;\nsomecode()")
|
||||||
False
|
False
|
||||||
"""
|
"""
|
||||||
pattern_template = r"""(?x)
|
pattern_template = r"""(?x)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue