Fix whitespace being stripped from the comment before filtering.
This makes it possible to filter whitespace spam.
This commit is contained in:
parent
c9209dd672
commit
b83c2c9811
@ -3,7 +3,7 @@ Get =
|
|||||||
{OP} = thread
|
{OP} = thread
|
||||||
excerpt = "/#{thread.board}/ - " + (
|
excerpt = "/#{thread.board}/ - " + (
|
||||||
OP.info.subject?.trim() or
|
OP.info.subject?.trim() or
|
||||||
OP.info.comment.replace(/\n+/g, ' // ') or
|
OP.info.commentDisplay.replace(/\n+/g, ' // ') or
|
||||||
OP.info.nameBlock)
|
OP.info.nameBlock)
|
||||||
return "#{excerpt[...70]}..." if excerpt.length > 73
|
return "#{excerpt[...70]}..." if excerpt.length > 73
|
||||||
excerpt
|
excerpt
|
||||||
|
|||||||
@ -106,22 +106,28 @@ class Post
|
|||||||
# 'Comment too long'...
|
# 'Comment too long'...
|
||||||
# EXIF data. (/p/)
|
# EXIF data. (/p/)
|
||||||
# Rolls. (/tg/)
|
# Rolls. (/tg/)
|
||||||
# Marquees. (/pol/)
|
# Fortunes. (/s4s/)
|
||||||
|
bq = @nodes.comment.cloneNode true
|
||||||
|
for node in $$ '.abbr + br, .exif, b, .fortune', bq
|
||||||
|
$.rm node
|
||||||
|
if abbr = $ '.abbr', bq
|
||||||
|
$.rm abbr
|
||||||
|
@info.comment = @nodesToText bq
|
||||||
|
if abbr
|
||||||
|
@info.comment = @info.comment.replace /\n\n$/, ''
|
||||||
|
|
||||||
|
# Hide spoilers.
|
||||||
|
# Remove:
|
||||||
# Preceding and following new lines.
|
# Preceding and following new lines.
|
||||||
# Trailing spaces.
|
# Trailing spaces.
|
||||||
bq = @nodes.comment.cloneNode true
|
commentDisplay = @info.comment
|
||||||
for node in $$ '.abbr, .exif, b, marquee', bq
|
unless Conf['Remove Spoilers'] or Conf['Reveal Spoilers']
|
||||||
$.rm node
|
spoilers = $$ 's', bq
|
||||||
@info.comment = @nodesToText bq
|
if spoilers.length
|
||||||
|
for node in spoilers
|
||||||
# Get the comment's text with spoilers hidden.
|
$.replace node, $.tn '[spoiler]'
|
||||||
spoilers = $$ 's', bq
|
commentDisplay = @nodesToText bq
|
||||||
@info.commentSpoilered = if spoilers.length
|
@info.commentDisplay = commentDisplay.trim().replace /\s+$/gm, ''
|
||||||
for node in spoilers
|
|
||||||
$.replace node, $.tn '[spoiler]'
|
|
||||||
@nodesToText bq
|
|
||||||
else
|
|
||||||
@info.comment
|
|
||||||
|
|
||||||
nodesToText: (bq) ->
|
nodesToText: (bq) ->
|
||||||
text = ""
|
text = ""
|
||||||
@ -129,7 +135,7 @@ class Post
|
|||||||
i = 0
|
i = 0
|
||||||
while node = nodes.snapshotItem i++
|
while node = nodes.snapshotItem i++
|
||||||
text += node.data or '\n'
|
text += node.data or '\n'
|
||||||
text.trim().replace /\s+$/gm, ''
|
text
|
||||||
|
|
||||||
parseQuotes: ->
|
parseQuotes: ->
|
||||||
@quotes = []
|
@quotes = []
|
||||||
|
|||||||
@ -128,7 +128,7 @@ Unread =
|
|||||||
openNotification: (post) ->
|
openNotification: (post) ->
|
||||||
return unless Header.areNotificationsEnabled
|
return unless Header.areNotificationsEnabled
|
||||||
notif = new Notification "#{post.info.nameBlock} replied to you",
|
notif = new Notification "#{post.info.nameBlock} replied to you",
|
||||||
body: post.info[if Conf['Remove Spoilers'] or Conf['Reveal Spoilers'] then 'comment' else 'commentSpoilered']
|
body: post.info.commentDisplay
|
||||||
icon: Favicon.logo
|
icon: Favicon.logo
|
||||||
notif.onclick = ->
|
notif.onclick = ->
|
||||||
Header.scrollToIfNeeded post.nodes.root, true
|
Header.scrollToIfNeeded post.nodes.root, true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user