From a448b261d6bffa420d1f0c4d57ebe852146001bf Mon Sep 17 00:00:00 2001 From: cel Date: Mon, 23 Apr 2018 15:59:42 -1000 Subject: Fix double-html-escaped href --- lib/render-msg.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'lib/render-msg.js') diff --git a/lib/render-msg.js b/lib/render-msg.js index 4db7429..68c8147 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -36,10 +36,6 @@ RenderMsg.prototype.linkify = function (text) { return this.render.linkify(text) } -function token() { - return '__' + Math.random().toString(36).substr(2) + '__' -} - RenderMsg.prototype.raw = function (cb) { // linkify various things in the JSON. TODO: abstract this better @@ -52,7 +48,7 @@ RenderMsg.prototype.raw = function (cb) { // link to feed starting from this message if (m.value.sequence) { - var tok = token() + var tok = u.token() tokens[tok] = h('a', {href: this.toUrl(m.value.author + '?gt=' + (m.value.sequence-1))}, m.value.sequence) @@ -64,13 +60,13 @@ RenderMsg.prototype.raw = function (cb) { for (k in this.c) c[k] = this.c[k] // link to messages of same type - tok = token() + tok = u.token() tokens[tok] = h('a', {href: this.toUrl('/type/' + c.type)}, c.type) c.type = tok // link to channel if (c.channel) { - tok = token() + tok = u.token() tokens[tok] = h('a', {href: this.toUrl('#' + c.channel)}, c.channel) c.channel = tok } @@ -79,7 +75,7 @@ RenderMsg.prototype.raw = function (cb) { // TODO: recurse for (var k in c) { if (!c[k] || c[k][0] !== '#') continue - tok = token() + tok = u.token() tokens[tok] = h('a', {href: this.toUrl(c[k])}, c[k]) c[k] = tok } @@ -1501,7 +1497,7 @@ RenderMsg.prototype.imageMap = function (cb) { var self = this var imgLink = u.toLink(self.c.image) var imgRef = imgLink && imgLink.link - var mapName = 'map' + token() + var mapName = 'map' + u.token() self.wrap(h('div', [ h('map', {name: mapName}, u.toArray(self.c.areas).map(function (areaLink) { -- cgit v1.2.3