From 6f1b88a4c77410acb8a996cb68e5120e8f9ac94d Mon Sep 17 00:00:00 2001 From: teddit Date: Wed, 2 Dec 2020 17:02:32 +0100 Subject: [PATCH] all titles through cleanTitle() --- views/includes/head.pug | 4 ++++ views/index.pug | 4 ++-- views/post.pug | 10 +++++----- views/search.pug | 2 +- views/subreddit.pug | 4 ++-- views/user.pug | 4 ++-- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/views/includes/head.pug b/views/includes/head.pug index d23d899..70dbe0e 100644 --- a/views/includes/head.pug +++ b/views/includes/head.pug @@ -94,3 +94,7 @@ meta(name="viewport", content="width=device-width, initial-scale=1.0") function secondsToMMSS(time) { return new Date(time * 1000).toISOString().substr(14,5) } + + function cleanTitle(title) { + return title.replace(/&/g, '&') + } diff --git a/views/index.pug b/views/index.pug index d569e1c..9d8bc2b 100644 --- a/views/index.pug +++ b/views/index.pug @@ -82,11 +82,11 @@ html .title if link.is_self_link a(href="" + link.permalink + "") - h2 #{link.title} + h2 #{cleanTitle(link.title)} span (#{link.domain}) else a(href="" + link.url + "") - h2 #{link.title} + h2 #{cleanTitle(link.title)} span (#{link.domain}) .meta p.submitted submitted diff --git a/views/post.pug b/views/post.pug index e33f5f0..08d30b2 100644 --- a/views/post.pug +++ b/views/post.pug @@ -1,7 +1,7 @@ doctype html html head - title #{post.title} : #{subreddit} + title #{cleanTitle(post.title)} : #{subreddit} include includes/head.pug body(class=""+ user_preferences.theme +"") include includes/topbar.pug @@ -22,7 +22,7 @@ html div.arrow.down .title a(href="" + localize(post.url) + "") - h2 #{post.title} + h2 #{cleanTitle(post.title)} p.submitted span(title="" + toUTCString(post.created) + "") submitted #{timeDifference(post.created)} by a(href="/u/" + post.author + "") @@ -31,7 +31,7 @@ html .crosspost .title a(href="" + localize(post.crosspost.permalink) + "") - h2 #{post.crosspost.title} + h2 #{cleanTitle(post.crosspost.title)} .num_comments | #{post.crosspost.num_comments} comments .score @@ -85,13 +85,13 @@ html .video .title a(href="" + post.media.embed_src + "", target="_blank") - p #{post.media.title} + p #{cleanTitle(post.media.title)} .video-holder a(href="" + post.media.embed_src + "", target="_blank") img(src="" + post.media.thumbnail + "") div(class="youtube-info") p YouTube video info: - p #{post.media.title} #{post.media.embed_src} + p #{cleanTitle(post.media.title)} #{post.media.embed_src} p #{post.media.author_name} #{post.media.author_url} else if post.media.source === 'external' diff --git a/views/search.pug b/views/search.pug index 9268b5e..7e17736 100644 --- a/views/search.pug +++ b/views/search.pug @@ -105,7 +105,7 @@ html a(href="" + post.permalink + "") div.no-image .title - a(href="" + post.permalink + "") #{post.title} + a(href="" + post.permalink + "") #{cleanTitle(post.title)} .meta p.submitted(title="" + toUTCString(post.created) + "") submitted #{timeDifference(post.created)} by a(href="/u/" + post.author + "") #{post.author} diff --git a/views/subreddit.pug b/views/subreddit.pug index ccece52..ff6eaf2 100644 --- a/views/subreddit.pug +++ b/views/subreddit.pug @@ -82,11 +82,11 @@ html .title if link.is_self_link a(href="" + link.permalink + "") - h2 #{link.title} + h2 #{cleanTitle(link.title)} span (#{link.domain}) else a(href="" + link.url + "") - h2 #{link.title} + h2 #{cleanTitle(link.title)} span (#{link.domain}) .meta p.submitted submitted diff --git a/views/user.pug b/views/user.pug index acb336d..b751052 100644 --- a/views/user.pug +++ b/views/user.pug @@ -78,7 +78,7 @@ html a(href="" + post.permalink + "") div.no-image .title - a(href="" + post.permalink + "") #{post.title} + a(href="" + post.permalink + "") #{cleanTitle(post.title)} .meta p.submitted(title="" + toUTCString(post.created) + "") submitted #{timeDifference(post.created)} by a(href="/u/" + data.username + "") #{data.username} @@ -89,7 +89,7 @@ html .entry .meta .title - a(href="" + post.url + "") #{post.link_title} + a(href="" + post.url + "") #{cleanTitle(post.link_title)} .author p by if post.link_author !== '[deleted]'