diff --git a/src/General/Build.coffee b/src/General/Build.coffee
index 28d0b6d93..67cfd2a65 100755
--- a/src/General/Build.coffee
+++ b/src/General/Build.coffee
@@ -1,9 +1,6 @@
Build =
initPixelRatio: window.devicePixelRatio
spoilerRange: {}
- h_escape: (text) ->
- (text+'').replace /[&"'<>]/g, (c) ->
- {'&': '&', "'": ''', '"': '"', '<': '<', '>': '>'}[c]
unescape: (text) ->
return text unless text?
text.replace /&(amp|#039|quot|lt|gt);/g, (c) ->
@@ -74,7 +71,6 @@ Build =
This function contains code from 4chan-JS (https://github.com/4chan/4chan-JS).
@license: https://github.com/4chan/4chan-JS/blob/master/LICENSE
###
- E = Build.h_escape
{
postID, threadID, boardID
name, capcode, tripcode, uniqueID, email, subject, flagCode, flagName, date, dateUTC
diff --git a/src/General/Get.coffee b/src/General/Get.coffee
index 44e45b034..c13aa6a37 100755
--- a/src/General/Get.coffee
+++ b/src/General/Get.coffee
@@ -160,7 +160,7 @@ Get =
return
# convert comment to html
- h_comment = Build.h_escape (data.comment or '')
+ h_comment = E (data.comment or '')
# https://github.com/eksopl/fuuka/blob/master/Board/Yotsuba.pm#L413-452
# https://github.com/eksopl/asagi/blob/master/src/main/java/net/easymodo/asagi/Yotsuba.java#L109-138
h_comment = h_comment.replace ///
diff --git a/src/General/Globals.coffee b/src/General/Globals.coffee
index e301f775a..2334e7813 100755
--- a/src/General/Globals.coffee
+++ b/src/General/Globals.coffee
@@ -5,4 +5,7 @@ doc = d.documentElement
g =
VERSION: '<%= version %>'
NAMESPACE: '<%= meta.name %>.'
- boards: {}
\ No newline at end of file
+ boards: {}
+E = (text) ->
+ (text+'').replace /[&"'<>]/g, (x) ->
+ {'&': '&', "'": ''', '"': '"', '<': '<', '>': '>'}[x]
diff --git a/src/Miscellaneous/FileInfo.coffee b/src/Miscellaneous/FileInfo.coffee
index 4ec8b6183..a0fb1baac 100755
--- a/src/Miscellaneous/FileInfo.coffee
+++ b/src/Miscellaneous/FileInfo.coffee
@@ -13,23 +13,23 @@ FileInfo =
if c of FileInfo.h_formatters
FileInfo.h_formatters[c].call(post)
else
- Build.h_escape s
+ E s
h_formatters:
- t: -> Build.h_escape @file.URL.match(/\d+\..+$/)[0]
- T: -> "#{FileInfo.h_formatters.t.call @}"
- l: -> "#{FileInfo.h_formatters.n.call @}"
- L: -> "#{FileInfo.h_formatters.N.call @}"
+ t: -> E @file.URL.match(/\d+\..+$/)[0]
+ T: -> "#{FileInfo.h_formatters.t.call @}"
+ l: -> "#{FileInfo.h_formatters.n.call @}"
+ L: -> "#{FileInfo.h_formatters.N.call @}"
n: ->
fullname = @file.name
shortname = Build.shortFilename @file.name, @isReply
if fullname is shortname
- Build.h_escape fullname
+ E fullname
else
- "#{Build.h_escape shortname}#{Build.h_escape fullname}"
- N: -> Build.h_escape @file.name
+ "#{E shortname}#{E fullname}"
+ N: -> E @file.name
p: -> if @file.isSpoiler then 'Spoiler, ' else ''
- s: -> Build.h_escape @file.size
+ s: -> E @file.size
B: -> return "#{+@file.sizeInBytes} Bytes"
K: -> "#{+Math.round(@file.sizeInBytes/1024)} KB"
M: -> "#{+Math.round(@file.sizeInBytes/1048576*100)/100} MB"
- r: -> Build.h_escape (@file.dimensions or 'PDF')
+ r: -> E (@file.dimensions or 'PDF')