fix: fix newlines in poll option titles (#1717)

This commit is contained in:
Nolan Lawson 2020-03-01 13:54:08 -08:00 committed by GitHub
parent 464864cd3d
commit ec627f9732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -4,7 +4,7 @@
{#each options as option}
<li class="poll-choice option">
<div class="option-text">
<strong>{option.share}%</strong> <span>{@html option.title}</span>
<strong>{option.share}%</strong> <span>{@html cleanTitle(option.title)}</span>
</div>
<svg aria-hidden="true">
<line x1="0" y1="0" x2="{option.share}%" y2="0" />
@ -23,7 +23,7 @@
value="{i}"
on:change="onChange()"
>
<span>{@html option.title}</span>
<span>{@html cleanTitle(option.title)}</span>
</label>
</li>
{/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
}