From ec627f97322ef35ea198d6114b42fb4d3bcf998c Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sun, 1 Mar 2020 13:54:08 -0800 Subject: [PATCH] fix: fix newlines in poll option titles (#1717) --- src/routes/_components/status/StatusPoll.html | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/routes/_components/status/StatusPoll.html b/src/routes/_components/status/StatusPoll.html index 4ab0943d..93258fd5 100644 --- a/src/routes/_components/status/StatusPoll.html +++ b/src/routes/_components/status/StatusPoll.html @@ -4,7 +4,7 @@ {#each options as option}
  • - {option.share}% {@html option.title} + {option.share}% {@html cleanTitle(option.title)}
    {@html option.title} + {@html cleanTitle(option.title)}
  • {/each} @@ -362,6 +362,14 @@ this.set({ choices: choices }) } }, + helpers: { + cleanTitle (title) { + // Remove newlines and tabs. + // Mastodon UI doesn't care because in CSS it's formatted to be single-line, but we care + // if people somehow insert newlines, because it can really mess up the formatting. + return (title && title.replace(/[\n\t]+/g, ' ')) || '' + } + }, components: { SvgIcon }