mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 01:57:15 +08:00
FIX: allow quote-less details BBCode
In 53b3d2f0dc460348a4c23e12f843ccf11426a080 we introduced a stricter BBCode Tag parser. It prevents having "values" with spaces when they're not surrounded by a valid pair of quotes. The `[details=` BBCode Tag is popular enough that it's worth adding a special case for it (especially since it doesn't support other parameters). This also adds the Finnish pair of quotes. Context - https://meta.discourse.org/t/details-accepts-only-one-word-as-summary/313019
This commit is contained in:
@ -1,23 +1,16 @@
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { module, test } from "qunit";
|
||||
import { cook } from "discourse/lib/text";
|
||||
|
||||
const opts = {
|
||||
siteSettings: {
|
||||
enable_emoji: true,
|
||||
emoji_set: "twitter",
|
||||
highlighted_languages: "json|ruby|javascript",
|
||||
default_code_lang: "auto",
|
||||
},
|
||||
censoredWords: "shucks|whiz|whizzer",
|
||||
getURL: (url) => url,
|
||||
};
|
||||
module("lib:details-cooked-test", (hooks) => {
|
||||
setupTest(hooks);
|
||||
|
||||
module("lib:details-cooked-test", function () {
|
||||
test("details", async function (assert) {
|
||||
test("details", async (assert) => {
|
||||
const testCooked = async (input, expected, text) => {
|
||||
const cooked = (await cook(input, opts)).toString();
|
||||
const cooked = (await cook(input)).toString();
|
||||
assert.strictEqual(cooked, expected, text);
|
||||
};
|
||||
|
||||
await testCooked(
|
||||
`<details><summary>Info</summary>coucou</details>`,
|
||||
`<details><summary>Info</summary>coucou</details>`,
|
||||
@ -25,12 +18,15 @@ module("lib:details-cooked-test", function () {
|
||||
);
|
||||
|
||||
await testCooked(
|
||||
"[details=testing]\ntest\n[/details]",
|
||||
`<details>
|
||||
<summary>
|
||||
testing</summary>
|
||||
<p>test</p>
|
||||
</details>`
|
||||
`[details=test'ing all the things]\ntest\n[/details]`,
|
||||
`<details>\n<summary>\ntest'ing all the things</summary>\n<p>test</p>\n</details>`,
|
||||
"details with spaces and a single quote"
|
||||
);
|
||||
|
||||
await testCooked(
|
||||
`[details=”test'ing all the things”]\ntest\n[/details]`,
|
||||
`<details>\n<summary>\ntest'ing all the things</summary>\n<p>test</p>\n</details>`,
|
||||
"details surrounded by finnish double quotes"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user