Skip to content

Commit bf7712c

Browse files
committed
fix: [[iframe]]のclass/align属性がパースされない問題を修正
ALLOWED_IFRAME_ATTRSにalignとclassが含まれておらず、 Wikidot本家の許可属性リストと不一致だった。
1 parent eff5b31 commit bf7712c

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

packages/parser/src/parser/rules/block/iframe.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
* - URL normalisation strips whitespace and control characters to prevent
1313
* evasion via character insertion.
1414
* - Only a specific set of HTML attributes is allowed (Wikidot filters
15-
* out `class` and `id`).
15+
* out `id` but permits `class`).
1616
*
17-
* Allowed attributes: `width`, `height`, `style`, `scrolling`, `frameborder`.
17+
* Allowed attributes: `align`, `class`, `frameborder`, `height`,
18+
* `scrolling`, `style`, `width`.
1819
*
1920
* @module
2021
*/
@@ -25,9 +26,17 @@ import { parseBlockName } from "./utils";
2526

2627
/**
2728
* Whitelist of attributes permitted on `[[iframe]]`. Wikidot strips
28-
* `class` and `id` for security reasons.
29+
* `id` but permits `class`.
2930
*/
30-
const ALLOWED_IFRAME_ATTRS = new Set(["width", "height", "style", "scrolling", "frameborder"]);
31+
const ALLOWED_IFRAME_ATTRS = new Set([
32+
"align",
33+
"class",
34+
"frameborder",
35+
"height",
36+
"scrolling",
37+
"style",
38+
"width",
39+
]);
3140

3241
/**
3342
* Normalises a URL string for security checks by removing whitespace and

tests/fixtures/iframe/basic/expected.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"data": {
2020
"url": "https://example.com/",
2121
"attributes": {
22+
"class": "iframe",
2223
"width": "90%"
2324
}
2425
}
@@ -28,6 +29,7 @@
2829
"data": {
2930
"url": "https://example.com/",
3031
"attributes": {
32+
"class": "iframe",
3133
"style": "width: 90%"
3234
}
3335
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<p><iframe src="https://example.com/some-page" align="" frameborder="" height="" scrolling="" width="" class="" style=""></iframe></p>
22
<p><iframe src="http://example.org/http" align="" frameborder="" height="" scrolling="" width="" class="" style=""></iframe></p>
3-
<p><iframe src="https://example.com/" align="" frameborder="" height="" scrolling="" width="90%" class="" style=""></iframe></p>
4-
<p><iframe src="https://example.com/" align="" frameborder="" height="" scrolling="" width="" class="" style="width: 90%"></iframe></p>
3+
<p><iframe src="https://example.com/" align="" frameborder="" height="" scrolling="" width="90%" class="iframe" style=""></iframe></p>
4+
<p><iframe src="https://example.com/" align="" frameborder="" height="" scrolling="" width="" class="iframe" style="width: 90%"></iframe></p>

0 commit comments

Comments
 (0)