Move regex escaping to separate function.
This commit is contained in:
parent
c2b5a1f9f9
commit
407b5fe8a8
@ -196,6 +196,32 @@ Filter =
|
|||||||
if post.nodes.post.getBoundingClientRect().height
|
if post.nodes.post.getBoundingClientRect().height
|
||||||
new Notice 'info', 'MD5 filtered.', 2
|
new Notice 'info', 'MD5 filtered.', 2
|
||||||
|
|
||||||
|
escape: (value) ->
|
||||||
|
value.replace ///
|
||||||
|
/
|
||||||
|
| \\
|
||||||
|
| \^
|
||||||
|
| \$
|
||||||
|
| \n
|
||||||
|
| \.
|
||||||
|
| \(
|
||||||
|
| \)
|
||||||
|
| \{
|
||||||
|
| \}
|
||||||
|
| \[
|
||||||
|
| \]
|
||||||
|
| \?
|
||||||
|
| \*
|
||||||
|
| \+
|
||||||
|
| \|
|
||||||
|
///g, (c) ->
|
||||||
|
if c is '\n'
|
||||||
|
'\\n'
|
||||||
|
else if c is '\\'
|
||||||
|
'\\\\'
|
||||||
|
else
|
||||||
|
"\\#{c}"
|
||||||
|
|
||||||
menu:
|
menu:
|
||||||
init: ->
|
init: ->
|
||||||
return unless g.VIEW in ['index', 'thread'] and Conf['Menu'] and Conf['Filter']
|
return unless g.VIEW in ['index', 'thread'] and Conf['Menu'] and Conf['Filter']
|
||||||
@ -248,31 +274,7 @@ Filter =
|
|||||||
{type} = @dataset
|
{type} = @dataset
|
||||||
# Convert value -> regexp, unless type is MD5
|
# Convert value -> regexp, unless type is MD5
|
||||||
value = Filter[type] Filter.menu.post
|
value = Filter[type] Filter.menu.post
|
||||||
re = if type in ['uniqueID', 'MD5'] then value else value.replace ///
|
re = if type in ['uniqueID', 'MD5'] then value else Filter.escape(value)
|
||||||
/
|
|
||||||
| \\
|
|
||||||
| \^
|
|
||||||
| \$
|
|
||||||
| \n
|
|
||||||
| \.
|
|
||||||
| \(
|
|
||||||
| \)
|
|
||||||
| \{
|
|
||||||
| \}
|
|
||||||
| \[
|
|
||||||
| \]
|
|
||||||
| \?
|
|
||||||
| \*
|
|
||||||
| \+
|
|
||||||
| \|
|
|
||||||
///g, (c) ->
|
|
||||||
if c is '\n'
|
|
||||||
'\\n'
|
|
||||||
else if c is '\\'
|
|
||||||
'\\\\'
|
|
||||||
else
|
|
||||||
"\\#{c}"
|
|
||||||
|
|
||||||
re = if type in ['uniqueID', 'MD5']
|
re = if type in ['uniqueID', 'MD5']
|
||||||
"/#{re}/"
|
"/#{re}/"
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user