aboutsummaryrefslogtreecommitdiff
path: root/lib/util.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-08-23 12:39:53 -0700
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-08-23 12:39:53 -0700
commit679e08e0da36f829ffd8ec60e9e3beecab4b5925 (patch)
tree9c3c04293ad16d65df65beb7aae27cbe77dfc1e7 /lib/util.js
parent369f72529e83414099bdf037c3015cc9f61a038d (diff)
downloadpatchfoo-679e08e0da36f829ffd8ec60e9e3beecab4b5925.tar.gz
patchfoo-679e08e0da36f829ffd8ec60e9e3beecab4b5925.zip
Unescape HTML in image names for alt text
Diffstat (limited to 'lib/util.js')
-rw-r--r--lib/util.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/util.js b/lib/util.js
index 9f17966..58bb4b0 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -169,6 +169,15 @@ u.escapeHTML = function (html) {
.replace(/>/g, '&gt;')
}
+u.unescapeHTML = function (text) {
+ if (typeof text !== 'string') return text
+ return text.replace(/&amp;/g, '&')
+ .replace(/&quot;/g, '"')
+ .replace(/&#39;/g, '\'')
+ .replace(/&gt;/g, '>')
+ .replace(/&lt;/g, '<')
+}
+
u.pullSlice = function (start, end) {
if (end == null) end = Infinity
var offset = 0