Skip to content

Commit 6620b17

Browse files
authored
fix: handle p.quote-inline class in content parsing (#3504)
1 parent 4b5d747 commit 6620b17

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

app/components/status/StatusBody.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,8 @@ const vnode = computed(() => {
5555
.status-body.with-action p {
5656
cursor: pointer;
5757
}
58+
59+
.status-body .quote-inline {
60+
display: none;
61+
}
5862
</style>

app/composables/content-parse.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ const sanitizerBasicClasses = filterClasses(/^h-\S*|p-\S*|u-\S*|dt-\S*|e-\S*|men
2323
const sanitizer = sanitize({
2424
// Allow basic elements as seen in https://github.com/mastodon/mastodon/blob/17f79082b098e05b68d6f0d38fabb3ac121879a9/lib/sanitize_ext/sanitize_config.rb
2525
br: {},
26-
p: {},
26+
p: {
27+
class: filterClasses(/^quote-inline$/),
28+
},
2729
a: {
2830
href: filterHref(),
2931
class: sanitizerBasicClasses,

tests/nuxt/__snapshots__/html-parse.test.ts.snap

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,26 @@ exports[`html-parse > link + mention > html 1`] = `
142142
`;
143143
144144
exports[`html-parse > link + mention > text 1`] = `"Happy 🤗 we’re now using @vitest (migrated from chai+mocha) https://github.com/ayoayco/astro-reactive-library/pull/203"`;
145+
146+
exports[`html-parse > quote-inline > html 1`] = `
147+
"<p class="quote-inline" dir="auto">
148+
RE:
149+
<a
150+
href="https://tapbots.social/@example/123"
151+
rel="nofollow noopener noreferrer"
152+
target="_blank"
153+
><span class="invisible">https://</span
154+
><span class="ellipsis">tapbots.social/@example/123</span
155+
><span class="invisible">123</span></a
156+
>
157+
</p>
158+
<p></p>
159+
<p>Quoting post!</p>
160+
"
161+
`;
162+
163+
exports[`html-parse > quote-inline > text 1`] = `
164+
"RE: https://tapbots.social/@example/123123
165+
166+
Quoting post!"
167+
`;

tests/nuxt/html-parse.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ describe('html-parse', () => {
6262
expect(formatted).toMatchSnapshot('html')
6363
expect(serializedText).toMatchSnapshot('text')
6464
})
65+
66+
it('quote-inline', async () => {
67+
const { formatted, serializedText } = await render('<p class="quote-inline">RE: <a href="https://tapbots.social/@example/123" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">tapbots.social/@example/123</span><span class="invisible">123</span></a></p><p>Quoting post!</p>')
68+
expect(formatted).toMatchSnapshot('html')
69+
expect(serializedText).toMatchSnapshot('text')
70+
})
6571
})
6672

6773
async function render(input: string, options?: ContentParseOptions) {

0 commit comments

Comments
 (0)