HTML — 動的マークアップ挿入, DOM の構文解析 API と直列化 API, HTML の無毒化

8.4. 動的~markup挿入

注記: ~markupを文書の中へ動的に挿入するための~APIは、 構文解析器と相互作用するので,それらの挙動は[ `~HTML文書$(および`~HTML構文解析器$), `~XML文書$(および`~XML構文解析器$) ]のどちらで利用されるかに依存して変わる。 ◎ APIs for dynamically inserting markup into the document interact with the parser, and thus their behavior varies depending on whether they are used with HTML documents (and the HTML parser) or XML documents (and the XML parser).

各 `文書$には `動的~markup挿入-時には投出する~counter@ があり、 初期~時は 0 に設定するモノトスル。 この~counterは、 `~tokenから要素を作成-$する~algoと併用され,[ `~custom要素~構築子$が構文解析器から呼出されたとき,`文書$の[ `open()$m / `close()$m / `write()$m ]が利用-可能になる ]ことを防止するために利用される。 ◎ Document objects have a throw-on-dynamic-markup-insertion counter, which is used in conjunction with the create an element for the token algorithm to prevent custom element constructors from being able to use document.open(), document.close(), and document.write() when they are invoked by the parser. Initially, the counter must be set to zero.

8.4.1. 入力~streamの~open法

%document = %document.`open()$m
`文書$をその場で置換する — それまでの~objを再利用しつつ,それが新たな`文書$であったかのように。 その~objが返される。 ◎ Causes the Document to be replaced in-place, as if it was a new Document object, but reusing the previous object, which is then returned.
結果の`文書$には、 ~HTML構文解析器が結付けられる — それには `document.write()$c を利用して構文解析する~dataを与えれる。 ◎ The resulting Document has an HTML parser associated with it, which can be given data to parse using document.write().
`文書$が依然として構文解析-中にある場合、 この~methodの効果は無い。 ◎ The method has no effect if the Document is still being parsed.
次の場合、 `InvalidStateError$E 例外を投出する ⇒# `文書$は`~XML文書$である / `~custom要素~構築子$を現在~実行している ◎ Throws an "InvalidStateError" DOMException if the Document is an XML document. ◎ Throws an "InvalidStateError" DOMException if the parser is currently executing a custom element constructor.
%window = %document.`~openW(url, name, features)$m
`window.open()@~WINDOW#dom-window-open$c ~methodと同様に働く。 ◎ Works like the window.open() method.

各 `文書$には,真偽値をとる `作動中な構文解析器は中止されたか@ があり、 初期~時は ~F をとるとする。 これは、[ 文書にて`作動中な構文解析器$が中止された後 ]に[ ~scriptが[ `document.open()$c / `document.write()$c ]~methodを(直接間接問わず)呼出す ]ことを防止するために利用される。 ◎ Document objects have an active parser was aborted boolean, which is used to prevent scripts from invoking the document.open() and document.write() methods (directly or indirectly) after the document's active parser has been aborted. It is initially false.

`document.open 手続き@ は、 所与の ( %文書 ) に対し: ◎ The document open steps, given a document, are as follows:

  1. ~IF[ %文書 は`~XML文書$である ] ⇒ ~THROW `InvalidStateError$E ◎ If document is an XML document, then throw an "InvalidStateError" DOMException.
  2. ~IF[ %文書 の`動的~markup挿入-時には投出する~counter$ ~GT 0 ] ⇒ ~THROW `InvalidStateError$E ◎ If document's throw-on-dynamic-markup-insertion counter is greater than 0, then throw an "InvalidStateError" DOMException.
  3. %入口~文書 ~LET `入口~大域~obj$に`結付けられた文書$ ◎ Let entryDocument be the entry global object's associated Document.
  4. ~IF[ ( %文書 の`生成元$doc, %入口~文書 の`生成元$doc ) は`同一-生成元$でない ] ⇒ ~THROW `SecurityError$E ◎ If document's origin is not same origin to entryDocument's origin, then throw a "SecurityError" DOMException.
  5. ~IF[ %文書 には`作動中な構文解析器$がある ]~AND[ その`~script入子ng~level$ ~GT 0 ] ⇒ ~RET %文書 ◎ If document has an active parser whose script nesting level is greater than 0, then return document.

    注記: これは、 `document.open()$c が[ 構文解析-中に見出された~inline~script内で~callされたとき ]には,基本的に無視させる — ~timer~callbackや~event~handlerなどの,構文解析器によらない~taskから~callされたときには、 依然として効果があるようにしつつ。 ◎ This basically causes document.open() to be ignored when it's called in an inline script found during parsing, while still letting it have an effect when called from a non-parser task such as a timer callback or event handler.

  6. ~IF[ %文書 の`~unload~counter$ ~GT 0 ] ⇒ ~RET %文書 ◎ Similarly, if document's unload counter is greater than 0, then return document.

    注記: これは、 `document.open()$c が[ %文書 が~unloadされている間に[ `beforeunload$et / `pagehide$et / `unload$et ]~event~handlerから~callされたとき ]には,基本的に無視させる。 ◎ This basically causes document.open() to be ignored when it's called from a beforeunload, pagehide, or unload event handler while the Document is being unloaded.

  7. ~IF[ %文書 の`作動中な構文解析器は中止されたか$ ~EQ ~T ] ⇒ ~RET %文書 ◎ If document's active parser was aborted is true, then return document.

    注記: これは特に、 `document.open()$c が[ `~navi$が開始された後に~callされたとき ]には,初期~構文解析-の間に限り無視させる。 更なる背景0は `課題 #4723@~HTMLissue/4723$ を見よ。 ◎ This notably causes document.open() to be ignored if it is called after a navigation has started, but only during the initial parse. See issue #4723 for more background.

  8. ~IF[ %文書 の`~node~navigable$ ~NEQ ~NULL ]~AND[ %文書 の`~node~navigable$の`進行中な~navi$は`~navi~ID$である ] ⇒ `読込ngを停止する$( %文書 の`~node~navigable$ ) ◎ If document's node navigable is non-null and document's node navigable's ongoing navigation is a navigation ID, then stop loading document's node navigable.
  9. %文書 の ~EACH( `~shadowも含めた広義-子孫$ %~node ) に対し ⇒ `すべての~event~listener/~event~handlerを消去する$( %~node ) ◎ For each shadow-including inclusive descendant node of document, erase all event listeners and handlers given node.
  10. %~window ~LET %文書 に`関連な大域~obj$ ◎ ↓
  11. ~IF[ %文書 ~EQ %~window に`結付けられた文書$ ] ⇒ `すべての~event~listener/~event~handlerを消去する$( %~window ) ◎ If document is the associated Document of document's relevant global object, then erase all event listeners and handlers given document's relevant global object.
  12. `全~内容を~nodeで置換する$( %文書, ~NULL ) ◎ Replace all with null within document.
  13. ~IF[ %文書 は`全部的に作動中$である ]: ◎ If document is fully active:

    1. %新~URL ~LET %入口~文書 の`~URL$docの複製 ◎ Let newURL be a copy of entryDocument's URL.
    2. ~IF[ %入口~文書 ~NEQ %文書 ] ⇒ %新~URL の`素片$url ~SET ~NULL ◎ If entryDocument is not document, then set newURL's fragment to null.
    3. `~URLと履歴を更新する$( %文書, %新~URL ) ◎ Run the URL and history update steps with document and newURL.
  14. %文書 の`初期~about_blankか$doc ~SET ~F ◎ Set document's is initial about:blank to false.
  15. ~IF[ %文書 の`~iframe~loadは進捗-中か$ ~EQ ~T ] ⇒ %文書 の`~iframe~loadを黙らすか$ ~SET ~T ◎ If document's iframe load in progress flag is set, then set document's mute iframe load flag.
  16. %文書 の`~mode$doc ~SET `no-quirks^l ◎ Set document to no-quirks mode.
  17. %構文解析器 ~LET 新たな`~HTML構文解析器$ — その ⇒ `符号化法の確度$ ~SET `無関連^i ◎ Create a new HTML parser and associate it with document.\

    これは、 `~scriptにより作成された構文解析器@ と称される。 ◎ This is a script-created parser\

    それは、 次の 2 つを意味する:

    • [ `document.open()$c / `document.close()$m ]~methodにより~closeできる。
    • その~tokenizerは、 ~end-of-file~tokenを発する前に,明示的な `document.close()$m の~callを待機する。
    ◎ (meaning that it can be closed by the document.open() and document.close() methods, and that the tokenizer will wait for an explicit call to document.close() before emitting an end-of-file token). The encoding confidence is irrelevant.
  18. %構文解析器 を %文書 に結付ける ◎ ↑
  19. `挿入~地点$ ~SET `入力~stream$の終端の直前 (入力~streamは、 この時点で空になる。) ◎ Set the insertion point to point at just before the end of the input stream (which at this point will be empty).
  20. `文書の現在の準備度を更新する$( %文書, `loading^l ) ◎ Update the current document readiness of document to "loading".

    注記: これにより `readystatechange$et ~eventが発火されるが、 その~eventは,実際には作者~codeから観測-可能にならない — 上の段が,それを観測できる `すべての~event~listener/~event~handlerを消去する$ので。 ◎ This causes a readystatechange event to fire, but the event is actually unobservable to author code, because of the previous step which erased all event listeners and handlers that could observe it.

  21. ~RET %文書 ◎ Return document.

注記: `document.open 手続き$は、 `文書$が[ `~load後~task用に準備済み$, `完全に読込まれ$る ]のどちらになるかには影響しない。 ◎ The document open steps do not affect whether a Document is ready for post-load tasks or completely loaded.

`open(unused1, unused2)@m ~method手続きは ⇒ ~RET `document.open 手続き$( コレ ) ◎ The open(unused1, unused2) method must return the result of running the document open steps with this.

注記: %unused1, %unused2 引数は無視されるが、 1 〜 2 個の引数で関数を~callする~codeが働き続けられるよう,~IDLには保たれる。 それらは Web IDL の`多重定義~解決~algo$の規則に因り必要yである — その規則は、 引数が無い~callに対し `TypeError^E 例外を投出する。 `whatwg/webidl 課題 #581@https://github.com/whatwg/webidl/issues/581$ にて、 除去を許容するために~algoを変更することについて,究明-中にある。 `WEBIDL$r ◎ The unused1 and unused2 arguments are ignored, but kept in the IDL to allow code that calls the function with one or two arguments to continue working. They are necessary due to Web IDL overload resolution algorithm rules, which would throw a TypeError exception for such calls had the arguments not been there. whatwg/webidl issue #581 investigates changing the algorithm to allow for their removal. [WEBIDL]

`~openW(url, name, features)@m ~method手続きは: ◎ The open(url, name, features) method must run these steps:

  1. ~IF[ コレは`全部的に作動中$でない ] ⇒ ~THROW `InvalidAccessError$E ◎ If this is not fully active, then throw an "InvalidAccessError" DOMException.
  2. ~RET `~window~open手続き$( %url, %name, %features ) ◎ Return the result of running the window open steps with url, name, and features.

8.4.2. 入力~streamの~close法

%document.`close()$m
`document.open()$c ~methodで~openされた入力~streamを~closeする。 ◎ Closes the input stream that was opened by the document.open() method.
次の場合、 `InvalidStateError$E 例外を投出する ⇒# `文書$は`~XML文書$である / `~custom要素~構築子$を現在~実行している ◎ Throws an "InvalidStateError" DOMException if the Document is an XML document. ◎ Throws an "InvalidStateError" DOMException if the parser is currently executing a custom element constructor.

`Document$I の `close()@m ~method手続きは: ◎ The close() method must run the following steps:

  1. ~IF[ コレは`~XML文書$である ] ⇒ ~THROW `InvalidStateError$E ◎ If this is an XML document, then throw an "InvalidStateError" DOMException.
  2. ~IF[ コレの`動的~markup挿入-時には投出する~counter$ ~GT 0 ] ⇒ ~THROW `InvalidStateError$E ◎ If this's throw-on-dynamic-markup-insertion counter is greater than zero, then throw an "InvalidStateError" DOMException.
  3. %構文解析器 ~LET コレの`~scriptにより作成された構文解析器$は[ 在るならば それ / 無いならば ε ] ◎ ↓
  4. ~IF[ %構文解析器 ~EQ ε ] ⇒ ~RET ◎ If there is no script-created parser associated with this, then return.
  5. %構文解析器 の`入力~stream$の終端に`明示的な~EOF$を挿入する ◎ Insert an explicit "EOF" character at the end of the parser's input stream.
  6. ~IF[ コレの`構文解析器を阻んでいる~script$ ~NEQ ~NULL ] ⇒ ~RET ◎ If this's pending parsing-blocking script is not null, then return.
  7. %構文解析器 の~tokenizerを走らす ⇒ ~tokenizerから~tokenが発されるごとに,それを処理する。 [ ~tokenizerが`明示的な~EOF$に達するか,`~event~loopを回す$ ]時点で停止する。 ◎ Run the tokenizer, processing resulting tokens as they are emitted, and stopping when the tokenizer reaches the explicit "EOF" character or spins the event loop.

8.4.3. `document.write()^c

%document.`write(...text)$m
一般に,所与の文字列(たち)を`文書$の入力~streamに追加する。 ◎ In general, adds the given string(s) to the Document's input stream.
この~methodの挙動は、 とても特異的である。 一部の事例では、 `~HTML構文解析器$が走っている間に 構文解析器の状態に影響し得る — その結果、 文書の~sourceに対応しない~DOMになり得る (例:書込まれた文字列が `<plaintext>^l や `<!--^l であった場合など)。 別の事例では、 `document.open()$c が~callされていたかのように,現在の~pageをまず~clearすることもある。 さらには、 単純に無視されたり, 例外を投出する事例もある。 ~UAには、 この~methodを介して挿入された `script^e 要素に対しては, `実行するのを避けることが明示的に許容される@~HTMLparsing#document-written-scripts-intervention$。 この~methodの正確な挙動は、 ~network待時間に依存する事例すらあり、 とても~debugし難い失敗へ至らす。 これらすべての理由から、 この~methodの利用は,強く忌避される。 ◎ This method has very idiosyncratic behavior. In some cases, this method can affect the state of the HTML parser while the parser is running, resulting in a DOM that does not correspond to the source of the document (e.g. if the string written is the string "<plaintext>" or "<!--"). In other cases, the call can clear the current page first, as if document.open() had been called. In yet more cases, the method is simply ignored, or throws an exception. User agents are explicitly allowed to avoid executing script elements inserted via this method. And to make matters even worse, the exact behavior of this method can in some cases be dependent on network latency, which can lead to failures that are very hard to debug. For all these reasons, use of this method is strongly discouraged.
次の場合、 `InvalidStateError$E 例外を投出する ⇒# `文書$は`~XML文書$である / `~custom要素~構築子$を現在~実行している ◎ Throws an "InvalidStateError" DOMException when invoked on XML documents. ◎ Throws an "InvalidStateError" DOMException if the parser is currently executing a custom element constructor.

この~methodは、 `script$e や`~event~handler内容~属性$の様な危険にもなり得る[ 要素, 属性 ]を除去するための無毒化を遂行しない。 ◎ This method performs no sanitization to remove potentially-dangerous elements and attributes like script or event handler content attributes.

各 `文書$には `破壊的な書込nは無視する~counter@ があり、 初期~時は 0 に設定するモノトスル。 この~counterは、 `script$e 要素の処理と併用され,[ 外部~scriptが[ `document.write()$c を利用して,暗黙的に `document.open()$c を~callする ]ことにより文書を吹飛ばす ]ことを防止するために利用される。 ◎ Document objects have an ignore-destructive-writes counter, which is used in conjunction with the processing of script elements to prevent external scripts from being able to use document.write() to blow away the document by implicitly calling document.open(). Initially, the counter must be set to zero.

`document.write 手続き@ は、 所与の ( `文書$ %文書, ~list %~text, 真偽値 %~LFを付加するか, 文字列 %~sink ) に対し: ◎ The document write steps, given a Document object document, a list text, a boolean lineFeed, and a string sink, are as follows:

  1. ~Assert: %~text を成す各~itemは[ 文字列/ `TrustedHTML$I ~obj ]である。 【この段は、この訳による補完。】
  2. %文字列 ~LET 空~文字列 ◎ Let string be the empty string.
  3. %信用-済みか ~LET ~T ◎ ↓ Let isTrusted be false if text contains a string; otherwise true.
  4. %~text を成す ~EACH( %値 ) に対し: ◎ For each value of text:

    1. ~IF[ %値 は `TrustedHTML$I ~objである ] ⇒ %文字列 に %値 の`~data$tHを付加する ◎ If value is a TrustedHTML object, then append value's associated data to string.
    2. ~ELSE ⇒# %文字列 に %値 を付加する; %信用-済みか ~SET ~F ◎ Otherwise, append value to string.
  5. ~IF[ %信用-済みか ~EQ ~F ] ⇒ %文字列 ~SET `信用-済みな型に準拠な文字列を取得する$( ↓ ) ⇒# `TrustedHTML$I, コレに`関連な大域~obj$, %文字列, %~sink, `script^l ◎ If isTrusted is false, set string to the result of invoking the get trusted type compliant string algorithm with TrustedHTML, this's relevant global object, string, sink, and "script".
  6. ~IF[ %~LFを付加するか ~EQ ~T ] ⇒ %文字列 に `000A^U LINE FEED を付加する ◎ If lineFeed is true, append U+000A LINE FEED to string.
  7. ~IF[ %文書 は`~XML文書$である ] ⇒ ~THROW `InvalidStateError$E ◎ If document is an XML document, then throw an "InvalidStateError" DOMException.
  8. ~IF[ %文書 の`動的~markup挿入-時には投出する~counter$ ~GT 0 ] ⇒ ~THROW `InvalidStateError$E ◎ If document's throw-on-dynamic-markup-insertion counter is greater than 0, then throw an "InvalidStateError" DOMException.
  9. ~IF[ %文書 の`作動中な構文解析器は中止されたか$ ~EQ ~T ] ⇒ ~RET ◎ If document's active parser was aborted is true, then return.
  10. ~IF[ `挿入~地点$ ~EQ ε ]: ◎ If the insertion point is undefined:

    1. ~IF[ %文書 の`~unload~counter$ ~GT 0 ]~OR[ %文書 の`破壊的な書込nは無視する~counter$ ~GT 0 ] ⇒ ~RET ◎ If document's unload counter is greater than 0 or document's ignore-destructive-writes counter is greater than 0, then return.
    2. `document.open 手続き$( %文書 ) ◎ Run the document open steps with document.
  11. %文字列 を`入力~stream$内の`挿入~地点$に挿入する ◎ Insert string into the input stream just before the insertion point.
  12. ~IF[ %文書 の`構文解析器を阻んでいる~script$ ~EQ ~NULL ] ⇒ %文字列 を`~HTML構文解析器$に処理させる — 以下に従う下で: ◎ If document's pending parsing-blocking script is null, then have the HTML parser process string,\

    • 符号位置を 1 個ずつ与え,結果の~tokenが発される度にそれを処理する。 ◎ one code point at a time, processing resulting tokens as they are emitted,\
    • ~tokenizerが挿入~地点に達したときは、 停止する。 ◎ and stopping when the tokenizer reaches the insertion point\
    • ~tokenizerの処理が ~tree構築~段階にて中止されたときは、 停止する (これは、 `script$e 終了~tag~tokenが~tokenizerにより発された場合に起こり得る)。 ◎ or when the processing of the tokenizer is aborted by the tree construction stage (this can happen if a script end tag token is emitted by the tokenizer).

    注記: `document.write()$c が,~inlineに実行している~scriptから~callされた場合 (すなわち,構文解析器が `script$e を終了~tagまで構文解析したことにより,~callされた)、 これは,`構文解析器の再入呼出し@~HTMLparsing#nestedParsing$になる。 [ 構文解析器の`静止するか$ ~EQ ~T ]の場合、[ ~tokenizerにおける`静止するかの検査@~HTMLparsing#check-parser-pause-flag$ ]により,[ ~tokenizerは即時に中止され,~HTMLは構文解析されない ]ことになる。 ◎ If the document.write() method was called from script executing inline (i.e. executing because the parser parsed a set of script tags), then this is a reentrant invocation of the parser. If the parser pause flag is set, the tokenizer will abort immediately and no HTML will be parsed, per the tokenizer's parser pause flag check.

`Document$I の `write(...text)@m ~method手続きは ⇒ `document.write 手続き$( コレ, %text, ~F, `Document write^l ) ◎ The document.write(...text) method steps are to run the document write steps with this, text, false, and "Document write".

8.4.4. `document.writeln()^c

%document.`writeln(...text)$m
所与の文字列(たち)を `文書$の入力~streamに追加した上で、 改行文字も追加する。 必要yなら, `open()$m ~methodも暗黙的に~callする。 ◎ Adds the given string(s) to the Document's input stream, followed by a newline character. If necessary, calls the open() method implicitly first.
この~methodの挙動は、 とても特異的である。 `document.write()$c と同じ理由から、 この~methodの利用は,強く忌避される。 ◎ This method has very idiosyncratic behavior. Use of this method is strongly discouraged, for the same reasons as document.write().
次の場合、 `InvalidStateError$E 例外を投出する ⇒# `文書$は`~XML文書$である / `~custom要素~構築子$を現在~実行している ◎ Throws an "InvalidStateError" DOMException when invoked on XML documents. ◎ Throws an "InvalidStateError" DOMException if the parser is currently executing a custom element constructor.

この~methodは、 `script$e や`~event~handler内容~属性$の様な危険にもなり得る[ 要素, 属性 ]を除去するための無毒化を遂行しない。 ◎ This method performs no sanitization to remove potentially-dangerous elements and attributes like script or event handler content attributes.

`Document$I の `writeln(...text)@m ~method手続きは ⇒ `document.write 手続き$( コレ, %text, ~T, `Document writeln^l ) ◎ The document.writeln(...text) method steps are to run the document write steps with this, text, true, and "Document writeln".

8.5. ~DOMの構文解析~APIと直列化~API

partial interface `Element$I {
  [`CEReactions$] undefined `setHTML$m(DOMString %html, optional `SetHTMLOptions$I %options = {});
  [`CEReactions$] undefined `setHTMLUnsafe$m((`TrustedHTML$I or DOMString) %html, optional `SetHTMLUnsafeOptions$I %options = {});
  DOMString `getHTML$m(optional `GetHTMLOptions$I %options = {});

  [`CEReactions$] attribute (`TrustedHTML$I or [`LegacyNullToEmptyString$] DOMString) `innerHTML$m;
  [`CEReactions$] attribute (`TrustedHTML$I or [`LegacyNullToEmptyString$] DOMString) `outerHTML$m;
  [`CEReactions$] undefined `insertAdjacentHTML$m(DOMString position, (`TrustedHTML$I or DOMString) %string);
};

partial interface `ShadowRoot$I {
  [`CEReactions$] undefined `setHTML$m1(DOMString %html, optional `SetHTMLOptions$I %options = {});
  [`CEReactions$] undefined `setHTMLUnsafe$m1((`TrustedHTML$I or DOMString) %html, optional `SetHTMLUnsafeOptions$I %options = {});

  DOMString `getHTML$m1(optional `GetHTMLOptions$I options = {});

  [`CEReactions$] attribute (`TrustedHTML$I or [`LegacyNullToEmptyString$] DOMString) `innerHTML$m1;
};

enum `SanitizerPresets@I {
  `default$l
};
dictionary `SetHTMLOptions@I {
  (`Sanitizer$I or `SanitizerConfig$I or `SanitizerPresets$I) `sanitizer@mb = `default$l;
};
dictionary `SetHTMLUnsafeOptions@I {
  (`Sanitizer$I or `SanitizerConfig$I or `SanitizerPresets$I) `sanitizer@mbU = {};
  boolean `runScripts@mbU = false;
};
dictionary `ParseHTMLUnsafeOptions@I {
  (`Sanitizer$I or `SanitizerConfig$I or `SanitizerPresets$I) `sanitizer@mbP = {};
};

dictionary `GetHTMLOptions@I {
  boolean `serializableShadowRoots@mb = false;
  sequence<`ShadowRoot$I> `shadowRoots@mb = [];
};

8.5.1. `DOMParser^I ~interface

`DOMParser$I ~interfaceは、 文字列を[ ~HTML/~XML ]として構文解析して,新たな`文書$を作成することを,作者に許容する。 ◎ The DOMParser interface allows authors to create new Document objects by parsing strings, as either HTML or XML.

%parser = `new DOMParser()$m
新たな `DOMParser$I ~objを構築する。 ◎ Constructs a new DOMParser object.
%document = %parser.`parseFromString$m( %string, %type )
%string を[ %type に則って[ ~HTML構文解析器, ~XML構文解析器 ]いずれか ]を利用する下で構文解析して,結果の`文書$を返す。 ◎ Parses string using either the HTML or XML parser, according to type, and returns the resulting Document.\
%type は、 次に挙げるいずれかをとり得る ⇒# `text/html$mt, `text/xml$mt, `application/xml$mt, `application/xhtml+xml$mt, `image/svg+xml$mt ◎終 これらのうち[ `text/html^mt は~HTML構文解析器/ 他は~XML構文解析器 ]を呼出すことになる。 ◎ type can be "text/html" (which will invoke the HTML parser), or any of "text/xml", "application/xml", "application/xhtml+xml", or "image/svg+xml" (which will invoke the XML parser).
~XML構文解析器においては、 %string を構文解析できない場合に返される`文書$は, 結果の~errorを述べている要素たちを包含することになる。 ◎ For the XML parser, if string cannot be parsed, then the returned Document will contain elements describing the resulting error.
構文解析の間は, `script$e 要素は評価されないことに加え、 結果の文書の`符号化法$docは,常に`~UTF-8$になることに注意。 文書の`~URL$docは, %parser に`関連な大域~obj$から継承されることになる。 ◎ Note that script elements are not evaluated during parsing, and the resulting document's encoding will always be UTF-8. The document's URL will be inherited from parser's relevant global object.
上に挙げたもの以外の %type 値は、 【 `DOMParserSupportedType$I 値でないので,】 `TypeError^E 例外を投出させることになる。 ◎ Values other than the above for type will cause a TypeError exception to be thrown.

注記: `DOMParser$I の設計が,~classとして構築してから `parseFromString()$m ~methodを~callする必要があるのは、 不幸な歴史的~遺物である。 この機能性を今日に設計するなら,自立的な関数にするであろう。 ~HTMLを構文解析するための現代の代替は、 `Document$I の `parseHTMLUnsafe()$m である。 ◎ The design of DOMParser, as a class that needs to be constructed and then have its parseFromString() method called, is an unfortunate historical artifact. If we were designing this functionality today it would be a standalone function. For parsing HTML, the modern alternative is Document.parseHTMLUnsafe().

この~methodは、 `script$e や`~event~handler内容~属性$の様な危険にもなり得る[ 要素, 属性 ]を除去するための無毒化を遂行しない。 ◎ This method performs no sanitization to remove potentially-dangerous elements and attributes like script or event handler content attributes.

[Exposed=Window]
interface `DOMParser@I {
  `constructor@#dom-domparser-constructor$();

  [NewObject] `Document$I `parseFromString$m((`TrustedHTML$I or DOMString) %string, `DOMParserSupportedType$I %type);
};

enum `DOMParserSupportedType@I {
  `text/html$l,
  `text/xml$l,
  `application/xml$l,
  `application/xhtml+xml$l,
  `image/svg+xml$l
};
`new DOMParser()@m 構築子~手続きは、 何もしない。 ◎ The new DOMParser() constructor steps are to do nothing.

`parseFromString(string, type)@m ~method手続きは: ◎ The parseFromString(string, type) method steps are:

  1. %準拠な文字列 ~LET `信用-済みな型に準拠な文字列を取得する$( ↓ ) ⇒# `TrustedHTML$I, コレに`関連な大域~obj$, %string, `DOMParser parseFromString^l, `script^l ◎ Let compliantString be the result of invoking the get trusted type compliant string algorithm with TrustedHTML, this's relevant global object, string, "DOMParser parseFromString", and "script".
  2. %文書 ~LET 新たな`文書$ — その ⇒# `内容~型$doc ~SET %type, `~URL$doc ~SET コレに`関連な大域~obj$に`結付けられた文書$の`~URL$doc ◎ Let document be a new Document, whose content type is type and URL is this's relevant global object's associated Document's URL.

    %文書 の`符号化法$docは、 既定の`~UTF-8$のままにされることになる。 特に, %準拠な文字列 を構文解析する間に見出された どの[ ~XML宣言/ `meta$e 要素 ]にも効果は無い。 ◎ The document's encoding will be left as its default, of UTF-8. In particular, any XML declarations or meta elements found while parsing compliantString will have no effect.

  3. ~IF[ %type ~EQ `text/html@l ] ⇒ `文字列から~HTMLを構文解析する$( %文書, %準拠な文字列 ) ◎ Switch on type: ◎ "text/html" • Parse HTML from a string given document and compliantString.

    注記: %文書 が`属する閲覧~文脈$は無いので、 %文書 用の`~scriptingは不能化される$。 ◎ Since document does not have a browsing context, scripting is disabled.

  4. ~ELSE: ◎ Otherwise

    1. %構文解析器 ~LET 新たな`~XML構文解析器$ — その`~XML~scriptingの~supportは不能化する@~HTMLxml#xml-scripting-support-disabled$ ◎ Create an XML parser parser, associated with document, and with XML scripting support disabled.
    2. %構文解析器 を %文書 に結付ける ◎ ↑
    3. %構文解析器 を利用して %準拠な文字列 を構文解析する ◎ Parse compliantString using parser.
    4. ~IF[ 前~段の結果は[ ~XML整形式性 / ~XML名前空間 整形式性 ]~errorになった ]: ◎ If the previous step resulted in an XML well-formedness or XML namespace well-formedness error:

      1. ~Assert: %文書 には子~nodeは無い。 ◎ Assert: document has no child nodes.
      2. %根 ~LET `要素を作成する$( %文書, `parsererror^l, `http://www.mozilla.org/newlayout/xml/parsererror.xml^l ) ◎ Let root be the result of creating an element given document, "parsererror", and "http://www.mozilla.org/newlayout/xml/parsererror.xml".
      3. 任意選択で ⇒ 構文解析~errorの資質を述べるような属性や子を %根 に追加する ◎ Optionally, add attributes or children to root to describe the nature of the parsing error.
      4. `~nodeを付加する$( %根, %文書 ) ◎ Append root to document.
  5. ~RET %文書 ◎ Return document.

`文字列から~HTMLを構文解析する@ ~algoは、 所与の ( `文書$ %文書, `文字列$ %~HTML ) に対し: ◎ To parse HTML from a string, given a Document document and a string html:

  1. %文書 の`種別$doc ~SET `html^l ◎ Set document's type to "html".
  2. %構文解析器 ~LET 新たな`~HTML構文解析器$ — その ⇒ `符号化法の確度$ ~SET `無関連^i ◎ ↓
  3. %構文解析器 を %文書 に結付ける ◎ ↓
  4. %構文解析器 の`入力~stream$の中へ %~HTML を設置する ◎ Create an HTML parser parser, associated with document. ◎ ↑ Place html into the input stream for parser.\ The encoding confidence is irrelevant.
  5. %構文解析器 を開始して,挿入した %文字列 を成すすべての文字を消費するまで走らす ◎ Start parser and let it run until it has consumed all the characters just inserted into the input stream.

    注記: 文書の`~mode$docは、 この段で変異するかもしれない。 ◎ This might mutate the document's mode.

8.5.2. ~HTML構文解析~method

%element.`setHTML(html, options)$m
~HTML構文解析器を利用して %html を~option群 %options の下で構文解析する — その結果で %element の子~群を置換する。 %element が,当の~HTML構文解析器~用の文脈を供する。 構文解析された素片は、 %options の `sanitizer$mb ~memberに基づいて`無毒化-$されることに加え, `安全でない内容は除去される$。 ◎ Parses html using the HTML parser with options options, and replaces the children of element with the result. element provides context for the HTML parser. The parsed fragment is sanitized based on the options's "sanitizer" member, and unsafe content is removed.
%shadowRoot.`setHTML(html, options)$m1
~HTML構文解析器を利用して %html を~option群 %options の下で構文解析する — その結果で %shadowRoot の子~群を置換する。 %shadowRoot の`~host$が,当の~HTML構文解析器~用の文脈を供する。 構文解析された素片は、 %options の `sanitizer$mb ~memberに基づいて`無毒化-$されることに加え, `安全でない内容は除去される$。 ◎ Parses html using the HTML parser with options options, and replaces the children of shadowRoot with the result. shadowRoot's host provides context for the HTML parser. The parsed fragment is sanitized based on the options's "sanitizer" member, and unsafe content is removed.
%element.`setHTMLUnsafe(html, options)$m
~HTML構文解析器を利用して %html を~option群 %options の下で構文解析する — その結果で %element の子~群を置換する。 %element が,当の~HTML構文解析器~用の文脈を供する。 構文解析された素片は、 %element の中へ挿入される前に, %options の `sanitizer$mbU ~memberに基づいて`無毒化-$される。 【!If the options dictionary contains】 %options の `runScripts$mbU ~memberが ~T をとる場合、 %html 内に包含される各~scriptは,~node~treeが更新された直後に実行されることになる。 ◎ Parses html using the HTML parser with options options, and replaces the children of element with the result. element provides context for the HTML parser. If the options dictionary contains a "sanitizer" member, it is used to sanitize the parsed fragment before it is inserted into element. If the options dictionary's "runScripts" member is true, scripts contained in html will be executed immediately after the node tree is updated.
%shadowRoot.`setHTMLUnsafe(html, options)$m1
~HTML構文解析器を利用して %html を~option群 %options の下で構文解析する — その結果で %shadowRoot の子~群を置換する。 %shadowRoot の`~host$が,当の~HTML構文解析器~用の文脈を供する。 構文解析された素片は、 %shadowRoot の中へ挿入される前に, %options の `sanitizer$mbU ~memberに基づいて`無毒化-$される。 【!If the options dictionary contains】 %options の `runScripts$mbU ~memberが ~T をとる場合、 %html 内に包含される各~scriptは,~node~treeが更新された直後に実行されることになる。 ◎ Parses html using the HTML parser with options options, and replaces the children of shadowRoot with the result. shadowRoot's host provides context for the HTML parser. If the options dictionary contains a "sanitizer" member, it is used to sanitize the parsed fragment before it is inserted into shadowRoot. If the options dictionary's "runScripts" member is true, scripts contained in html will be executed immediately after the node tree is updated.
%doc = `Document$I.`parseHTML(html, options)$m
~HTML構文解析器を利用して %html を~option群 %options の下で構文解析して, その結果を包含している新たな`文書$を返す。 結果の文書は、 %options の `sanitizer$mb ~memberに基づいて`無毒化-$されることに加え, `安全でない内容は除去される$。 ◎ Parses html using the HTML parser with options options, and returns a new Document containing the result. The resulting document is sanitized based on the options's "sanitizer" member, and unsafe content is removed.
%doc = `Document$I.`parseHTMLUnsafe(html, options)$m
~HTML構文解析器を利用して %html を~option群 %options の下で構文解析した結果の`文書$を返す。 ◎ Parses html using the HTML parser with options options, and returns the resulting Document.
[ `script$e 要素は,構文解析する間に評価されない ]ことに加え,[ 結果の文書の`符号化法$docは,常に `~UTF-8$ になる ]ことに注意。 文書の`~URL$docは `~about_blank$sc になる。 結果の~DOMは、 %options の `sanitizer$mbP ~memberに基づいて`無毒化-$される。 【!If the options dictionary contains】 ◎ Note that script elements are not evaluated during parsing, and the resulting document's encoding will always be UTF-8. The document's URL will be about:blank. If the options dictionary contains a "sanitizer" member, it is used to sanitize the resulting DOM.

これらの~methodのうち,名前に `Unsafe^c を伴うものは、[ `script$e や `~event~handler内容~属性$の様な危険になり得る要素や属性 ]を除去するための無毒化を遂行しない。 ◎ The methods with an Unsafe suffix perform no sanitization to remove potentially-dangerous elements and attributes like script or event handler content attributes.

`Element$I の `setHTML(html, options)@m ~method手続きは: ◎ Element's setHTML(html, options) method steps are:

  1. %~target ~LET コレに応じて ⇒# `template$e 要素であるならば コレの`~template内容$ / ~ELSE_ コレ ◎ Let target be this's template contents if this is a template element; otherwise this.
  2. `~HTMLを設定して~filterする$( ↓ ) ⇒# %~target, コレ, %html, %options, ~T ◎ Set and filter HTML given target, this, html, options, and true.
`ShadowRoot$I の `setHTML(html, options)@m1 ~method手続きは ⇒ `~HTMLを設定して~filterする$( ↓ ) ⇒# コレ, コレの`~host$, %html, %options, ~T ◎ ShadowRoot's setHTML(html, options) method steps are: • Set and filter HTML given this, this's shadow host, html, options, and true.

`Element$I の `setHTMLUnsafe(html, options)@m ~method手続きは: ◎ Element's setHTMLUnsafe(html, options) method steps are:

  1. %準拠な~HTML ~LET `信用-済みな型に準拠な文字列を取得する$( ↓ ) ⇒# `TrustedHTML$I, コレに`関連な大域~obj$, %html, `Element setHTMLUnsafe^l, `script^l ◎ Let compliantHTML be the result of invoking the get trusted type compliant string algorithm with TrustedHTML, this's relevant global object, html, "Element setHTMLUnsafe", and "script".
  2. %~target ~LET コレに応じて ⇒# `template$e 要素であるならば コレの`~template内容$ / ~ELSE_ コレ ◎ Let target be this's template contents if this is a template element; otherwise this.
  3. `~HTMLを設定して~filterする$( ↓ ) ⇒# %~target, コレ, %準拠な~HTML, %options, ~F ◎ Set and filter HTML given target, this, compliantHTML, options, and false.

`ShadowRoot$I の `setHTMLUnsafe(html, options)@m1 ~method手続きは: ◎ ShadowRoot's setHTMLUnsafe(html, options) method steps are:

  1. %準拠な~HTML ~LET `信用-済みな型に準拠な文字列を取得する$( ↓ ) ⇒# `TrustedHTML$I, コレに`関連な大域~obj$, %html, `ShadowRoot setHTMLUnsafe^l, `script^l ◎ Let compliantHTML be the result of invoking the get trusted type compliant string algorithm with TrustedHTML, this's relevant global object, html, "ShadowRoot setHTMLUnsafe", and "script".
  2. `~HTMLを設定して~filterする$( ↓ ) ⇒# コレ, コレの`~host$, %準拠な~HTML, %options, ~F ◎ Set and filter HTML given this, this's shadow host, compliantHTML, options, and false.

静的な `parseHTML(html, options)@m ~method手続きは: ◎ The static parseHTML(html, options) method steps are:

  1. %文書 ~LET `新たな~obj$( `Document$I ) ◎ Let document be a new Document,\ ↓ whose content type is "text/html".

    注記: %文書 が`属する閲覧~文脈$は無いので、 %文書 用の`~scriptingは不能化される$。 ◎ Since document does not have a browsing context, scripting is disabled.

  2. %文書 の ⇒# `内容~型$doc ~SET `text/html^l, `宣言的な~shadow根を許容するか$doc ~SET ~T ◎ ↑ Set document's allow declarative shadow roots to true.
  3. `文字列から~HTMLを構文解析する$( %文書, %html ) ◎ Parse HTML from a string given document and html.
  4. %無毒化器 ~LET `~option群から無毒化器~instanceを取得する$( %options, ~T ) ◎ Let sanitizer be the result of calling get a sanitizer instance from options with options and true.
  5. `~nodeを無毒化する$( %文書, %無毒化器, ~T ) ◎ Call sanitize on document with sanitizer and true.
  6. ~RET %文書 ◎ Return document.

静的な `parseHTMLUnsafe(html, options)@m ~method手続きは: ◎ The static parseHTMLUnsafe(html, options) method steps are:

  1. %準拠な~HTML ~LET `信用-済みな型に準拠な文字列を取得する$( ↓ ) ⇒# `TrustedHTML$I, コレに`関連な大域~obj$, %html, `Document parseHTMLUnsafe^l, `script^l ◎ Let compliantHTML be the result of invoking the get trusted type compliant string algorithm with TrustedHTML, this's relevant global object, html, "Document parseHTMLUnsafe", and "script".
  2. %文書 ~LET 新たな`文書$ — その ⇒# `内容~型$doc ~SET `text/html^l ◎ Let document be a new Document, whose content type is "text/html".

    注記: %文書 が`属する閲覧~文脈$は無いので、 %文書 用の`~scriptingは不能化される$。 ◎ Since document does not have a browsing context, scripting is disabled.

  3. %文書 の`宣言的な~shadow根を許容するか$doc ~SET ~T ◎ Set document's allow declarative shadow roots to true.
  4. `文字列から~HTMLを構文解析する$( %文書, %準拠な~HTML ) ◎ Parse HTML from a string given document and compliantHTML.
  5. %無毒化器 ~LET `~option群から無毒化器~instanceを取得する$( %options, ~F ) ◎ Let sanitizer be the result of calling get a sanitizer instance from options with options and false.
  6. `~nodeを無毒化する$( %文書, %無毒化器, ~F ) ◎ Call sanitize on document with sanitizer and false.
  7. ~RET %文書 ◎ Return document.

8.5.3 ~HTMLの直列化~method

%html = %element.`getHTML(options)$m ◎ html = element.getHTML({ serializableShadowRoots, shadowRoots })

%element を~HTMLへ直列化した結果を返す。 %element の中の各`~shadow根$は、 供された各~optionに則って直列化される: ◎ Returns the result of serializing element to HTML. Shadow roots within element are serialized according to the provided options:

  • %options[ "`serializableShadowRoots$mb" ] ~EQ ~T の場合、 次を満たす~shadow根は,すべて直列化される ⇒ `直列化-可能か$sR ~EQ ~T ◎ If serializableShadowRoots is true, then all shadow roots marked as serializable are serialized.
  • %options[ "`shadowRoots$mb" ] に供された配列~内に指定された すべての~shadow根は、 その`直列化-可能か$sRを問わず,直列化される。 ◎ If the shadowRoots array is provided, then all shadow roots specified in the array are serialized, regardless of whether or not they are marked as serializable.

どちらの~optionも供されなかった場合、 直列化される~shadow根は無い。 ◎ If neither option is provided, then no shadow roots are serialized.

%html = %shadowRoot.`getHTML(options)$m1 ◎ html = shadowRoot.getHTML({ serializableShadowRoots, shadowRoots })
%shadowRoot を~HTMLへ直列化した結果を返す — 文脈~要素として %shadowRoot の`~host$を利用する下で。 %shadowRoot の中の`~shadow根$は、 上と同じく,供された各~optionに則って直列化される。 ◎ Returns the result of serializing shadowRoot to HTML, using its shadow host as the context element. Shadow roots within shadowRoot are serialized according to the provided options, as above.
`Element$I の `getHTML(options)@m ~method手続きは ⇒ ~RET `~HTML素片~直列化~algo$( コレ, %options[ "`serializableShadowRoots$mb" ], %options[ "`shadowRoots$mb" ] ) ◎ Element's getHTML(options) method steps are to return the result of HTML fragment serialization algorithm with this, options["serializableShadowRoots"], and options["shadowRoots"].
`ShadowRoot$I の `getHTML(options)@m1 ~method手続きは ⇒ ~RET `~HTML素片~直列化~algo$( コレ, %options[ "`serializableShadowRoots$mb" ], %options[ "`shadowRoots$mb" ] ) ◎ ShadowRoot's getHTML(options) method steps are to return the result of HTML fragment serialization algorithm with this, options["serializableShadowRoots"], and options["shadowRoots"].

8.5.4. `innerHTML^m ~prop

`innerHTML$m ~propには、 `DOMPARSING$r の`課題~追跡器@https://github.com/w3c/DOM-Parsing/issues$において,いくつか未決な課題がある — そこには、 その仕様に伴われる様々な問題が文書化されている。 ◎ The innerHTML property has a number of outstanding issues in the DOM Parsing and Serialization issue tracker, documenting various problems with its specification.

%element.`innerHTML$m
%element の内容を表現する[[ ~HTML/~XML ]を成す素片 ]を返す。 ◎ Returns a fragment of HTML or XML that represents the element's contents.
~XML文書の事例では、 %element を~XMLへ直列化できない場合には, `InvalidStateError$E 例外を投出する。 ◎ In the case of an XML document, throws an "InvalidStateError" DOMException if the element cannot be serialized to XML.
%element.`innerHTML$m = %value
所与の文字列を構文解析した結果の~nodeたちで, %element の内容を置換する。 ◎ Replaces the contents of the element with nodes parsed from the given string.
~XML文書の事例では、 所与の文字列は整形式でない場合には, `SyntaxError$E 例外を投出する。 ◎ In the case of an XML document, throws a "SyntaxError" DOMException if the given string is not well-formed.
%shadowRoot.`innerHTML$m1
%element の内容を表現する[ ~HTMLを成す素片 ]を返す。 ◎ Returns a fragment of HTML that represents the shadow roots's contents.
%shadowRoot.`innerHTML$m1 = %value
所与の文字列を構文解析した結果の~nodeたちで, %shadowRoot の内容を置換する。 ◎ Replaces the contents of the shadow root with nodes parsed from the given string.

これらの~propの設定子は、 `script$e や`~event~handler内容~属性$の様な危険にもなり得る[ 要素, 属性 ]を除去するための無毒化を遂行しない。 ◎ These properties' setters perform no sanitization to remove potentially-dangerous elements and attributes like script or event handler content attributes.

`素片に直列化する@ ~algoは、 所与の ( [ `要素$/`文書$/`文書片$ ] %~node, 真偽値 %整形式が要求されるか ) に対し ⇒ ~RET %~node の`~node文書$に応じて ⇒# `~HTML文書$であるならば `~HTML素片~直列化~algo$( %~node, ~F, « » ) / `~XML文書$であるならば `~XML直列化$( %~node, %整形式が要求されるか ) ◎ The fragment serializing algorithm steps, given an Element, Document, or DocumentFragment node and a boolean require well-formed, are: • Let context document be node's node document. • If context document is an HTML document, return the result of HTML fragment serialization algorithm with node, false, and « ». • Return the XML serialization of node given require well-formed.

`素片を構文解析する@ ~algoは、 所与の ⇒# `要素$ %文脈, 文字列 %~markup, `構文解析器~用の~scripting~mode$ %~scripting~mode ~DF `不活$i ◎終 に対し: ◎ The fragment parsing algorithm steps, given an Element context, a string markup, and an optional parser scripting mode scriptingMode (default Inert), are:

  1. ~Assert: %~scripting~mode ~IN { `不活$i, `素片$i } ◎ Assert: scriptingMode is either Inert or Fragment.
  2. %新たな子~群 ~LET %文脈 の`~node文書$に応じて: ◎ Let newChildren be null.

    • `~XML文書$である ⇒ `~XML素片の構文解析~algo$( %文脈, %~markup ) ◎ If context's node document is an XML document, then set newChildren to the result of invoking the XML fragment parsing algorithm given context and markup.
    • `~HTML文書$である ⇒ `~HTML素片の構文解析~algo$( %文脈, %~markup, ~F, %~scripting~mode ) ◎ Otherwise, set newChildren to the result of invoking the HTML fragment parsing algorithm given context, markup, false, and scriptingMode.
  3. %文書片 ~LET 新たな`文書片$ — その ⇒ `~node文書$ ~SET %文脈 の`~node文書$ ◎ Let fragment be a new DocumentFragment whose node document is context's node document.
  4. %新たな子~群 を成す ~EACH( %~node ) に対し【!不要:`~tree順序$で】 ⇒ `~nodeを付加する$( %~node, %文書片 ) ◎ For each node of newChildren, in tree order: append node to fragment.

    注記: これは、 %~node 用の`~node文書$が正しくなることを確保する。 ◎ This ensures the node document for the new nodes is correct.

  5. ~RET %文書片 ◎ Return fragment.

`Element$I の `innerHTML@m 属性の ◎ ↓

  • 取得子~手続きは ⇒ ~RET `素片に直列化する$( コレ, ~T ) ◎ Element's innerHTML getter steps are to return the result of running fragment serializing algorithm steps with this and true. ◎ ↓ ShadowRoot's innerHTML getter steps are to return the result of running fragment serializing algorithm steps with this and true.

  • 設定子~手続きは: ◎ Element's innerHTML setter steps are:

    1. %準拠な文字列 ~LET `信用-済みな型に準拠な文字列を取得する$( ↓ ) ⇒# `TrustedHTML$I, コレに`関連な大域~obj$, 所与の値, `Element innerHTML^l, `script^l ◎ Let compliantString be the result of invoking the get trusted type compliant string algorithm with TrustedHTML, this's relevant global object, the given value, "Element innerHTML", and "script".
    2. %文脈 ~LET コレ ◎ Let context be this.
    3. %文書片 ~LET `素片を構文解析する$( %文脈, %準拠な文字列 ) ◎ Let fragment be the result of invoking the fragment parsing algorithm steps with context and compliantString.
    4. ~IF[ %文脈 は `template$e 要素である ] ⇒ %文脈 ~SET %文脈 の`~template内容$ (ある`文書片$) ◎ If context is a template element, then set context to the template element's template contents (a DocumentFragment).

      注記: `template$e 要素に対し `innerHTML$m を設定した場合、 その`子~群$ではなく,その`~template内容$を成すすべての~nodeを置換することになる。 ◎ Setting innerHTML on a template element will replace all the nodes in its template contents rather than its children.

    5. `全~内容を~nodeで置換する$( %文脈, %文書片 ) ◎ Replace all with fragment within context.

`ShadowRoot$I の `innerHTML@m1 属性の: ◎ ↓

  • 取得子~手続きは ⇒ ~RET `素片に直列化する$( コレ, ~T ) ◎ ↑
  • 設定子~手続きは: ◎ ShadowRoot's innerHTML setter steps are:

    1. %準拠な文字列 ~LET `信用-済みな型に準拠な文字列を取得する$( ↓ ) ⇒# `TrustedHTML$I, コレに`関連な大域~obj$, 所与の値, `ShadowRoot innerHTML^l, `script^l ◎ Let compliantString be the result of invoking the get trusted type compliant string algorithm with TrustedHTML, this's relevant global object, the given value, "ShadowRoot innerHTML", and "script".
    2. %文脈 ~LET コレの`~host$ ◎ Let context be this's host.
    3. %文書片 ~LET `素片を構文解析する$( %文脈, %準拠な文字列 ) ◎ Let fragment be the result of invoking the fragment parsing algorithm steps with context and compliantString.
    4. `全~内容を~nodeで置換する$( コレ, %文書片 ) ◎ Replace all with fragment within this.

8.5.5. `outerHTML^m ~prop

`outerHTML$m ~propには、 `DOMPARSING$r の`課題~追跡器@https://github.com/w3c/DOM-Parsing/issues$において,いくつか未決な課題がある — そこには、 その仕様に伴われる様々な問題が文書化されている。 ◎ The outerHTML property has a number of outstanding issues in the DOM Parsing and Serialization issue tracker, documenting various problems with its specification.

%element.`outerHTML$m
[ %element とその内容 ]を表現する[[ ~HTML/~XML ]を成す素片 ]を返す。 ◎ Returns a fragment of HTML or XML that represents the element and its contents.
~XML文書の事例では、 %element を~XMLに直列化できない場合, `InvalidStateError$E 例外が投出される。 ◎ In the case of an XML document, throws an "InvalidStateError" DOMException if the element cannot be serialized to XML.
%element.`outerHTML$m = %value
%element を[ 所与の文字列から構文解析した結果の~nodeたち ]で置換する。 ◎ Replaces the element with nodes parsed from the given string.
~XML文書の事例では、 所与の文字列は整形式でない場合, `SyntaxError$E 例外が投出される。 ◎ In the case of an XML document, throws a "SyntaxError" DOMException if the given string is not well-formed.
%element の親は`文書$である場合、 `NoModificationAllowedError$E 例外が投出される。 ◎ Throws a "NoModificationAllowedError" DOMException if the parent of the element is a Document.

この~propの設定子は、 `script$e や`~event~handler内容~属性$の様な危険にもなり得る[ 要素, 属性 ]を除去するための無毒化を遂行しない。 ◎ This property's setter performs no sanitization to remove potentially-dangerous elements and attributes like script or event handler content attributes.

`Element$I の `outerHTML@m 属性の: ◎ ↓

  • 取得子~手続きは: ◎ Element's outerHTML getter steps are:

    1. %文書片 ~LET 新たな`文書片$ — その ⇒ `~node文書$ ~SET コレの`~node文書$ ◎ Let element be a fictional node\
    2. `~nodeを付加する$( コレ, %文書片 ) ◎ whose only child is this.
    3. ~RET `素片に直列化する$( %文書片, ~T ) ◎ Return the result of running fragment serializing algorithm steps with element and true.

    【 %文書片 は、 要素~自身の~tagも含めて直列化するために必要になる — これは、 原文では “`fictional node^en (架空な~node)” としか記されていないが, `文書片$で用を成すであろう。 】

  • 設定子~手続きは: ◎ Element's outerHTML setter steps are:

    1. %準拠な文字列 ~LET `信用-済みな型に準拠な文字列を取得する$( ↓ ) ⇒# `TrustedHTML$I, コレに`関連な大域~obj$, 所与の値, `Element outerHTML^l, `script^l ◎ Let compliantString be the result of invoking the get trusted type compliant string algorithm with TrustedHTML, this's relevant global object, the given value, "Element outerHTML", and "script".
    2. %親 ~LET コレの`親$ ◎ Let parent be this's parent.
    3. ~IF[ %親 ~EQ ~NULL ] ⇒ ~RET (以降の手続きを走らせても,作成される~nodeへの参照を得する仕方はないので。) ◎ If parent is null, return. There would be no way to obtain a reference to the nodes created even if the remaining steps were run.
    4. ~IF[ %親 は`文書$である ] ⇒ ~THROW `NoModificationAllowedError$E ◎ If parent is a Document, throw a "NoModificationAllowedError" DOMException.
    5. ~IF[ %親 は`文書片$である ] ⇒ %親 ~LET `要素を作成する$( コレの`~node文書$, `body^l, `~HTML名前空間$ ) ◎ If parent is a DocumentFragment, set parent to the result of creating an element given this's node document, "body", and the HTML namespace.
    6. %文書片 ~LET `素片を構文解析する$( %親, %準拠な文字列 ) ◎ Let fragment be the result of invoking the fragment parsing algorithm steps given parent and compliantString.
    7. `子を~nodeで置換する$( コレの`親$, コレ, %文書片 ) ◎ Replace this with fragment within this's parent.

8.5.6. `insertAdjacentHTML()^m ~method

`insertAdjacentHTML()$m ~methodには、 `DOMPARSING$r の`課題~追跡器@https://github.com/w3c/DOM-Parsing/issues$において,いくつか未決な課題がある — そこには、 その仕様に伴われる様々な問題が文書化されている。 ◎ The insertAdjacentHTML() method has a number of outstanding issues in the DOM Parsing and Serialization issue tracker, documenting various problems with its specification.

%element.`insertAdjacentHTML(position, string)$m

%string を[ ~HTML/~XML ]として構文解析した上で、 その結果の~nodeを[ %position に応じて次に与える位置 ]に挿入する: ◎ Parses string as HTML or XML and inserts the resulting nodes into the tree in the position given by the position argument, as follows:

`beforebegin^l
%element の前 (すなわち,直前の同胞との合間) ◎ Before the element itself (i.e., after element's previous sibling)
`afterbegin^l
%element の内側の先頭 (すなわち,最初の子の前) ◎ Just inside the element, before its first child.
`beforeend^l
%element の内側の末尾 (すなわち,最後の子の後) ◎ Just inside the element, after its last child.
`afterend^l
%element の後 (すなわち,直後の同胞との合間) ◎ After the element itself (i.e., before element's next sibling)
引数の値が妥当でない場合、 `SyntaxError$E 例外が投出される (例:`~XML文書$の事例では、 所与の文字列が整形式でない場合)。 ◎ Throws a "SyntaxError" DOMException if the arguments have invalid values (e.g., in the case of an XML document, if the given string is not well-formed).
所与の位置に挿入し得ない場合、 `NoModificationAllowedError$E 例外が投出される (例: `文書$の根~要素の後に要素を挿入しようとしたとき)。 ◎ Throws a "NoModificationAllowedError" DOMException if the given position isn't possible (e.g. inserting elements after the root element of a Document).

この~methodは、 `script$e や`~event~handler内容~属性$の様な危険にもなり得る[ 要素, 属性 ]を除去するための無毒化を遂行しない。 ◎ This method performs no sanitization to remove potentially-dangerous elements and attributes like script or event handler content attributes.

`Element$I の `insertAdjacentHTML(position, string)@m ~method手続きは: ◎ Element's insertAdjacentHTML(position, string) method steps are:

  1. %準拠な文字列 ~LET `信用-済みな型に準拠な文字列を取得する$( ↓ ) ⇒# `TrustedHTML$I, コレに`関連な大域~obj$, %string, `Element insertAdjacentHTML^l, `script^l ◎ Let compliantString be the result of invoking the get trusted type compliant string algorithm with TrustedHTML, this's relevant global object, string, "Element insertAdjacentHTML", and "script".
  2. %文脈 ~LET ~NULL ◎ Let context be null.
  3. %position ~LET `~ASCII小文字~化する$( %position ) ◎ ↓
  4. %position に応じて: ◎ Use the first matching item from this list:

    `beforebegin^l ◎ If position is an ASCII case-insensitive match for the string "beforebegin"
    `afterend^l ◎ If position is an ASCII case-insensitive match for the string "afterend"
    1. %文脈 ~SET コレの`親$ ◎ Set context to this's parent.
    2. ~IF[ %文脈 ~EQ ~NULL ]~OR[ %文脈 は`文書$である ] ⇒ ~THROW `NoModificationAllowedError$E ◎ If context is null or a Document, throw a "NoModificationAllowedError" DOMException.
    `afterbegin^l ◎ If position is an ASCII case-insensitive match for the string "afterbegin"
    `beforeend^l ◎ If position is an ASCII case-insensitive match for the string "beforeend"
    %文脈 ~SET コレ ◎ Set context to this.
    他の場合 ◎ Otherwise
    ~THROW `SyntaxError$E ◎ Throw a "SyntaxError" DOMException.
  5. ~IF[ %文脈 は`要素$でない ]~OR[ ~AND↓ ]… ◎ If context is not an Element or all of the following are true:

    • %文脈 の`~node文書$は`~HTML文書$である ◎ context's node document is an HTML document;
    • %文脈 の`局所~名$el ~EQ "`html$e" ◎ context's local name is "html"; and
    • %文脈 の`名前空間$el ~EQ `~HTML名前空間$ ◎ context's namespace is the HTML namespace,

    …ならば ⇒ %文脈 ~SET `要素を作成する$( コレの`~node文書$, `body^l, `~HTML名前空間$ ) ◎ then set context to the result of creating an element given this's node document, "body", and the HTML namespace.

  6. %文書片 ~LET `素片を構文解析する$( %文脈, %準拠な文字列 ) ◎ Let fragment be the result of invoking the fragment parsing algorithm steps with context and compliantString.
  7. %position に応じて: ◎ Use the first matching item from this list:

    `beforebegin^l ◎ If position is an ASCII case-insensitive match for the string "beforebegin"
    `~nodeを子の直前に挿入する$( %文書片, コレの`親$, コレ ) ◎ Insert fragment into this's parent before this.
    `afterbegin^l ◎ If position is an ASCII case-insensitive match for the string "afterbegin"
    `~nodeを子の直前に挿入する$( %文書片, コレ, コレの`最初の子?$ ) ◎ Insert fragment into this before its first child.
    `beforeend^l ◎ If position is an ASCII case-insensitive match for the string "beforeend"
    `~nodeを付加する$( %文書片, コレ ) ◎ Append fragment to this.
    `afterend^l ◎ If position is an ASCII case-insensitive match for the string "afterend"
    `~nodeを子の直前に挿入する$( %文書片, コレの`親$, コレの`直後の同胞?$ ) ◎ Insert fragment into this's parent before this's next sibling.

注記: `~node$を直に操作する他の~APIと同じく(および `innerHTML$m とは違って )、 `insertAdjacentHTML()$m は, `template$e 要素 %要素 に対する特別な取扱いを含まない。 ほとんどの事例では、 %要素 の子~nodeたちを直に操作する代わりに, %要素 の`~template内容$に対し `insertAdjacentHTML()$m を利用することが求まれよう。 ◎ As with other direct Node-manipulation APIs (and unlike innerHTML), insertAdjacentHTML() does not include any special handling for template elements. In most cases you will want to use templateEl.content.insertAdjacentHTML() instead of directly manipulating the child nodes of a template element.

8.5.7. `createContextualFragment()^m ~method

`createContextualFragment()$m ~methodには、 `DOMPARSING$r の`課題~追跡器@https://github.com/w3c/DOM-Parsing/issues$において,いくつか未決な課題がある — そこには、 その仕様に伴われる様々な問題が文書化されている。 ◎ The createContextualFragment() method has a number of outstanding issues in the DOM Parsing and Serialization issue tracker, documenting various problems with its specification.

%docFragment = %range.`createContextualFragment(string)$m
~markup文字列 %string から作成される`文書片$を返す — %string を構文解析する際の文脈として, %range の`始端~node$を利用する下で。 ◎ Returns a DocumentFragment created from the markup string string using range's start node as the context in which fragment is parsed.

この~methodは、 `script$e や`~event~handler内容~属性$の様な危険にもなり得る[ 要素, 属性 ]を除去するための無毒化を遂行しない。 ◎ This method performs no sanitization to remove potentially-dangerous elements and attributes like script or event handler content attributes.

partial interface `Range$I {
  [`CEReactions$, NewObject] `DocumentFragment$I `createContextualFragment$m((`TrustedHTML$I or DOMString) %string);
};

`createContextualFragment(string)@m ~method手続きは: ◎ Range's createContextualFragment(string) method steps are:

  1. %準拠な文字列 ~LET `信用-済みな型に準拠な文字列を取得する$( ↓ ) ⇒# `TrustedHTML$I, コレに`関連な大域~obj$, %string, `Range createContextualFragment^l, `script^l ◎ Let compliantString be the result of invoking the get trusted type compliant string algorithm with TrustedHTML, this's relevant global object, string, "Range createContextualFragment", and "script".
  2. %~node ~LET コレの`始端~node$ ◎ Let node be this's start node.
  3. %要素 ~LET ~NULL ◎ Let element be null.
  4. ~IF[ %~node は `Element$I を`実装-$する ] ⇒ %要素 ~SET %~node ◎ If node implements Element, set element to node.
  5. ~ELIF[ %~node は `Text$I を`実装-$する ]~OR[ %~node は `Comment$I を`実装-$する ] ⇒ %要素 ~SET %~node の`親~要素$ ◎ Otherwise, if node implements Text or Comment, set element to node's parent element.
  6. ~IF[ %要素 ~EQ ~NULL ]~OR[ ~AND↓ ]… ◎ If element is null or all of the following are true:

    • %要素 の`~node文書$は~HTML文書である ◎ element's node document is an HTML document;
    • %要素 の`局所~名$el ~EQ "`html$e" ◎ element's local name is "html"; and
    • %要素 の`名前空間$el ~EQ `~HTML名前空間$ ◎ element's namespace is the HTML namespace,

    …ならば ⇒ %要素 ~SET `要素を作成する$( コレの`~node文書$, `body^l, `~HTML名前空間$ ) ◎ then set element to the result of creating an element given this's node document, "body", and the HTML namespace.

  7. ~RET `素片を構文解析する$( %要素, %準拠な文字列, `素片$i ) ◎ Return the result of invoking the fragment parsing algorithm steps with element, compliantString, and Fragment.

8.5.8. `XMLSerializer^I ~interface

`XMLSerializer$I ~interfaceには、 `DOMPARSING$r の`課題~追跡器@https://github.com/w3c/DOM-Parsing/issues$において,いくつか未決な課題がある — そこには、 その仕様に伴われる様々な問題が文書化されている。 `DOMPARSING$r を成す残りは、 次第に この仕様へ~upstreamされることになる。 ◎ The XMLSerializer interface has a number of outstanding issues in the DOM Parsing and Serialization issue tracker, documenting various problems with its specification. The remainder of DOM Parsing and Serialization will be gradually upstreamed to this specification.

%xmlSerializer = `new XMLSerializer()$m
新たな `XMLSerializer$I ~objを構築する。 ◎ Constructs a new XMLSerializer object.
%string = %xmlSerializer . `serializeToString(root)$m
%root を直列化した結果を返す。 ◎ Returns the result of serializing root to XML.
%root を~XMLへ直列化できない場合、 `InvalidStateError$E 例外が投出される。 ◎ Throws an "InvalidStateError" DOMException if root cannot be serialized to XML.

`XMLSerializer$I の設計が,~classとして構築してから `serializeToString()$m ~methodを~callする必要があるのは、 不幸な歴史的~遺物である。 この機能性を今日に設計するなら,自立的な関数にするであろう。 ◎ The design of XMLSerializer, as a class that needs to be constructed and then have its serializeToString() method called, is an unfortunate historical artifact. If we were designing this functionality today it would be a standalone function.

[Exposed=Window]
interface `XMLSerializer@I {
  `constructor@#dom-xmlserializer-constructor$();

  DOMString `serializeToString$m(`Node$I %root);
};
`new XMLSerializer()@m 構築子~手続きは、 何もしない。 ◎ The new XMLSerializer() constructor steps are to do nothing.
`serializeToString(root)@m ~method手続きは ⇒ ~RET `~XML直列化$( %root, ~F ) ◎ The serializeToString(root) method steps are: • Return the XML serialization of root given false.

8.6. ~HTMLの無毒化

【 この節に現れる( `Sanitizer$I を~~構成するものとして利用される)語 “要素”, “属性” は、 ほとんどが,それらの型を識別する名前 — ( 名前, 名前空間 ) が成す組 — を意味することに注意 (個々の~nodeではなく)。 】

8.6.1. 序論

◎非規範的

~web~appは、 信用-済みでない~HTML文字列を処理する必要があることが多い — 利用者が生成した内容を具現化するときや, ~client側~templateを利用しているときなど。 ~DOMに基づく~XSS( `cross-site scripting^en )攻撃を防止するためには、 これらの文字列を~DOMの中へ安全に挿入する際に注意深い無毒化が要求される。 ◎ Web applications often need to process untrusted HTML strings, such as when rendering user-generated content or using client-side templates. Safely inserting these strings into the DOM requires careful sanitization to prevent DOM-based cross-site scripting (XSS) attacks.

~HTMLの無毒化は、 ~HTML文字列を安全に構文解析して無毒化するための~nativeな仕組みを供する。 それは、 ~UAの自前の~HTML構文解析器を利用して,無毒化された出力が[ 当の~browserが内容を どう具現化することになるか ]を正確aに反映することを確保する — ~script実行を防止して, 先進的な攻撃 — `~script~gadget@https://github.com/google/security-research-pocs/tree/master/script-gadgets$など — を軽減するよう。 ◎ HTML sanitization provides a native mechanism for safely parsing and sanitizing HTML strings. By using the user agent's own HTML parser, they ensure the sanitized output accurately reflects how the browser will render the content, preventing script execution and mitigating advanced attacks such as script gadgets.

これらの~APIを成す~method 【特定的には, `§ ~HTML構文解析~method@#html-parsing-methods$に定義されるもの】 は、[ ~HTMLを包含している文字列を~DOM~treeへ構文解析して, 結果の~treeを利用者が給した環境設定に則って~filterする ]ための機能性を提供する。 これらの~methodは、 “安全なもの”, “安全でないもの” 【~method名に `Unsafe^c を伴わないもの, 伴うもの】 に大別される。 ◎ These APIs offer functionality to parse a string containing HTML into a DOM tree, and to filter the resulting tree according to a user-supplied configuration. The methods come in two main flavors: "safe" and "unsafe".

8.6.1.1. 安全か否か

“安全な” ~methodは、 ~scriptを実行する~markupを生成しない — すなわち、 ~XSSに対し安全になることが意図される。 “安全でない” ~methodは、 供された環境設定に基づいて[ 構文解析して, ~filterする ]ことになるが, 既定では “安全” な~methodと同じ安全性を保証しない。 ◎ The "safe" methods will not generate any markup that executes script. That is, they are intended to be safe from XSS. The "unsafe" methods will parse and filter based on the provided configuration, but do not have the same safety guarantees by default.

8.6.2. `Sanitizer^I ~interface

[Exposed=Window]
interface `Sanitizer@I {
  `constructor@#dom-sanitizer-constructor$(optional (`SanitizerConfig$I or `SanitizerPresets$I) %configuration = `default$l);

  /* 
環境設定を~queryする:
◎
Query configuration:
 */
  `SanitizerConfig$I `get$m();

  /* 
この無毒化器の`環境設定$を成す各種[
~list/~field
]を改変する:
◎
Modify a Sanitizer's lists and fields:
 */
  boolean `allowElement$m(`SanitizerElementWithAttributes$I %element);
  boolean `removeElement$m(`SanitizerElement$I %element);
  boolean `replaceElementWithChildren$m(`SanitizerElement$I %element);
  boolean `allowProcessingInstruction$m(`SanitizerPI$I %pi);
  boolean `removeProcessingInstruction$m(`SanitizerPI$I %pi);
  boolean `allowAttribute$m(`SanitizerAttribute$I %attribute);
  boolean `removeAttribute$m(`SanitizerAttribute$I %attribute);
  boolean `setComments$m(boolean %allow);
  boolean `setDataAttributes$m(boolean %allow);

  /* 
~scriptを実行する~markupを除去するよう環境設定する:
◎
Remove markup that executes script.
 */
  boolean `removeUnsafe$m();
};
%config = %sanitizer.`get$m()
当の無毒化器( %sanitizer )の環境設定( `SanitizerConfig$I )の複製を返す。 ◎ Returns a copy of the sanitizer's configuration.
%sanitizer.`allowElement(element)$m
当の無毒化器の環境設定が指定された要素を許容することを確保する。 ◎ Ensures that the sanitizer configuration allows the specified element.
%sanitizer.`removeElement(element)$m
当の無毒化器の環境設定が指定された要素を阻止することを確保する。 ◎ Ensures that the sanitizer configuration blocks the specified element.
%sanitizer.`replaceElementWithChildren(element)$m
当の無毒化器が指定された要素を除去する一方で,その子~nodeたちを保つよう環境設定する。 ◎ Configures the sanitizer to remove the specified element but keep its child nodes.
%sanitizer.`allowAttribute(attribute)$m
当の無毒化器が指定された属性を大域的に許容するよう環境設定する。 ◎ Configures the sanitizer to allow the specified attribute globally.
%sanitizer.`removeAttribute(attribute)$m
当の無毒化器が指定された属性を大域的に阻止するよう環境設定する。 ◎ Configures the sanitizer to block the specified attribute globally.
%sanitizer.`allowProcessingInstruction(pi)$m
当の無毒化器が指定された処理命令を許容するよう環境設定する。 ◎ Configures the sanitizer to allow the specified processing instruction.
%sanitizer.`removeProcessingInstruction(pi)$m
当の無毒化器が指定された処理命令を阻止するよう環境設定する。 ◎ Configures the sanitizer to block the specified processing instruction.
%sanitizer.`setComments(allow)$m
当の無毒化器が~commentを保全するかどうかを設定する。 ◎ Sets whether the sanitizer preserves comments.
%sanitizer.`setDataAttributes(allow)$m
当の無毒化器が~custom~data属性(例: `data-*$a )を保全するかどうかを設定する。 ◎ Sets whether the sanitizer preserves custom data attributes (e.g., data-*).
%sanitizer.`removeUnsafe()$m
当の無毒化器の環境設定を改変する — 安全でないなものと見なされる[ 要素, 属性 ]を自動的に除去するよう。 ◎ Modifies the configuration to automatically remove elements and attributes that are considered unsafe.

各 `Sanitizer$I ~objには `環境設定@ が結付けられる — それは、 `SanitizerConfig$I である。 【成功裡に構築されたならば、常に,`妥当$になる。】 ◎ A Sanitizer object has an associated configuration, which is a SanitizerConfig.

`new Sanitizer(configuration)@m 構築子~手続きは: ◎ The new Sanitizer(configuration) constructor steps are:

  1. ~IF[ %configuration は `SanitizerPresets$I 用の`文字列$である ]: ◎ If configuration is a SanitizerPresets string:

    1. ~Assert: %configuration ~EQ `default$l ◎ Assert: configuration is "default".
    2. %configuration ~SET `組込みの安全な既定の環境設定$ ◎ Set configuration to the built-in safe default configuration.
  2. `無毒化器を環境設定する$( コレ, %configuration, ~T ) ◎ Configure this given configuration and true.

`無毒化器を環境設定する@ ~algoは、 所与の ( `Sanitizer$I %無毒化器, 辞書 %環境設定, 真偽値 %その他諸々を許容するか† ) に対し: ◎ To configure a Sanitizer sanitizer, given a dictionary configuration and a boolean allowCommentsPIsAndDataAttributes:

【† “その他諸々” とは、[ ~comment( `Comment$I ), 処理命令( `ProcessingInstruction$I ), `~custom~data属性$( `data-*$a ) ]の総称を意味する (素直に訳すと長くなるので、 和訳では,このように略記する)。 】

  1. `環境設定を正準-化する$( %環境設定, %その他諸々を許容するか ) ◎ Canonicalize the configuration configuration with allowCommentsPIsAndDataAttributes.
  2. ~IF[ %環境設定 は`妥当$でない ] ⇒ ~THROW `TypeError$E ◎ If configuration is not valid, then throw a TypeError.
  3. %無毒化器 の`環境設定$ ~SET %環境設定 ◎ Set sanitizer's configuration to configuration.

`環境設定を正準-化する@ ~algoは、 所与の ( `SanitizerConfig$I %環境設定, 真偽値 %その他諸々を許容するか ) に対し: ◎ To canonicalize the configuration SanitizerConfig configuration with a boolean allowCommentsPIsAndDataAttributes:

  1. ~IF[ %環境設定[ "`elements$mb" ] ~EQ ε ]~AND[ %環境設定[ "`removeElements$mb" ] ~EQ ε ] ⇒ %環境設定[ "`removeElements$mb" ] ~SET « » ◎ If neither configuration["elements"] nor configuration["removeElements"] exists, then set configuration["removeElements"] to an empty list.
  2. ~IF[ %環境設定[ "`attributes$mb" ] ~EQ ε ]~AND[ %環境設定[ "`removeAttributes$mb" ] ~EQ ε ] ⇒ %環境設定[ "`removeAttributes$mb" ] ~SET « » ◎ If neither configuration["attributes"] nor configuration["removeAttributes"] exists, then set configuration["removeAttributes"] to an empty list.
  3. ~IF[ %環境設定[ "`processingInstructions$mb" ] ~EQ ε ]~AND[ %環境設定[ "`removeProcessingInstructions$mb" ] ~EQ ε ]: ◎ If neither configuration["processingInstructions"] nor configuration["removeProcessingInstructions"] exists:

    1. ~IF[ %その他諸々を許容するか ~EQ ~T ] ⇒ %環境設定[ "`removeProcessingInstructions$mb" ] ~SET « » ◎ If allowCommentsPIsAndDataAttributes is true, then set configuration["removeProcessingInstructions"] to an empty list.
    2. ~ELSE ⇒ %環境設定[ "`processingInstructions$mb" ] ~SET « » ◎ Otherwise, set configuration["processingInstructions"] to an empty list.
  4. ~IF[ %環境設定[ "`elements$mb" ] ~NEQ ε ]: ◎ If configuration["elements"] exists:

    1. %新たな要素~群 ~LET « » ◎ Let newElements be « ».
    2. %環境設定[ "`elements$mb" ] を成す ~EACH( %要素 ) に対し ⇒ %新たな要素~群 に次の結果を`付加する$ ⇒ `属性~群を伴う無毒化器~要素を正準-化する$( %要素 ) ◎ For each element of configuration["elements"], append the result of canonicalizing element to newElements.
    3. %環境設定[ "`elements$mb" ] ~SET %新たな要素~群 ◎ Set configuration["elements"] to newElements.
  5. ~IF[ %環境設定[ "`removeElements$mb" ] ~NEQ ε ] ⇒ %環境設定[ "`removeElements$mb" ] ~SET `無毒化器~用の要素~listを正準-化する$( %環境設定[ "`removeElements$mb" ] ) ◎ If configuration["removeElements"] exists, then set configuration["removeElements"] to the result of canonicalizing configuration["removeElements"].
  6. ~IF[ %環境設定[ "`attributes$mb" ] ~NEQ ε ] ⇒ %環境設定[ "`attributes$mb" ] ~SET `無毒化器~用の~listを正準-化する$( %環境設定[ "`attributes$mb" ] ) ◎ If configuration["attributes"] exists, then set configuration["attributes"] to the result of canonicalizing configuration["attributes"].
  7. ~IF[ %環境設定[ "`removeAttributes$mb" ] ~NEQ ε ] ⇒ %環境設定[ "`removeAttributes$mb" ] ~SET `無毒化器~用の~listを正準-化する$( %環境設定[ "`removeAttributes$mb" ] ) ◎ If configuration["removeAttributes"] exists, then set configuration["removeAttributes"] to the result of canonicalizing configuration["removeAttributes"].
  8. ~IF[ %環境設定[ "`replaceWithChildrenElements$mb" ] ~NEQ ε ] ⇒ %環境設定[ "`replaceWithChildrenElements$mb" ] ~SET `無毒化器~用の要素~listを正準-化する$( %環境設定[ "`replaceWithChildrenElements$mb" ] ) ◎ If configuration["replaceWithChildrenElements"] exists, then set configuration["replaceWithChildrenElements"] to the result of canonicalizing configuration["replaceWithChildrenElements"].
  9. ~IF[ %環境設定[ "`processingInstructions$mb" ] ~NEQ ε ] ⇒ %環境設定[ "`processingInstructions$mb" ] ~SET `無毒化器~用の処理命令~listを正準-化する$( %環境設定[ "`processingInstructions$mb" ] ) ◎ If configuration["processingInstructions"] exists, then set configuration["processingInstructions"] to the result of canonicalizing configuration["processingInstructions"].
  10. ~IF[ %環境設定[ "`removeProcessingInstructions$mb" ] ~NEQ ε ] ⇒ %環境設定[ "`removeProcessingInstructions$mb" ] ~SET `無毒化器~用の処理命令~listを正準-化する$( %環境設定[ "`removeProcessingInstructions$mb" ] ) ◎ If configuration["removeProcessingInstructions"] exists, then set configuration["removeProcessingInstructions"] to the result of canonicalizing configuration["removeProcessingInstructions"].
  11. ~IF[ %環境設定[ "`comments$mb" ] ~EQ ε ] ⇒ %環境設定[ "`comments$mb" ] ~SET %その他諸々を許容するか ◎ If configuration["comments"] does not exist, then set it to allowCommentsPIsAndDataAttributes.
  12. ~IF[ %環境設定[ "`attributes$mb" ] ~NEQ ε ]~AND[ %環境設定[ "`dataAttributes$mb" ] ~EQ ε ] ⇒ %環境設定[ "`dataAttributes$mb" ] ~SET %その他諸々を許容するか ◎ If configuration["attributes"] exists and configuration["dataAttributes"] does not exist, then set it to allowCommentsPIsAndDataAttributes.

`無毒化器~用の~listを正準-化する@ ~algoは、 所与の ( %~list ) に対し: ◎ To canonicalize a sanitizer list list:

  1. %新たな~list ~LET « » ◎ Let newList be « ».
  2. %~list を成す ~EACH( %~item ) に対し ⇒ %新たな~list に次の結果を`付加する$ ⇒ `無毒化器~用の名前を正準-化する$( %~item ) ◎ For each item in list, append the result of canonicalizing item to newList.
  3. ~RET %新たな~list ◎ Return newList.

`無毒化器~用の処理命令~listを正準-化する@ ~algoは、 所与の ( %~list ) に対し: ◎ To canonicalize a processing instruction list list:

  1. %新たな~list ~LET « » ◎ Let newList be « ».
  2. %~list を成す ~EACH( %~item ) に対し ⇒ %新たな~list に次の結果を`付加する$ ⇒ `無毒化器~用の処理命令を正準-化する$( %~item ) ◎ For each item in list, append the result of canonicalizing item to newList.
  3. ~RET %新たな~list ◎ Return newList.

`無毒化器~用の処理命令を正準-化する@ ~algoは、 所与の ( `SanitizerPI$I %~pi ) に対し:

  1. %~target ~LET ~SET %~pi に応じて ⇒# `文字列$であるならば %~pi / 辞書であるならば %~pi[ "`target$mb" ]
  2. ~RET «[ "`target$mb" → %~target ]»
◎ To canonicalize a processing instruction given a SanitizerPI pi: • If pi is a DOMString, then return «[ "target" → pi ]». • Assert: pi is a dictionary and pi["target"] exists. • Return «[ "target" → pi["target"] ]».

`無毒化器~用の名前を正準-化する@ ~algoは、 所与の ( [ `文字列$/ 辞書 ] %名前, 文字列 %既定の名前空間 ~DF ~NULL ) に対し:

  1. %名前空間 ~LET %既定の名前空間
  2. ~IF[ %名前 は`文字列$でない ]:

    1. ~Assert: %名前 は辞書である
    2. %名前 ~SET %名前[ `name^l ]
    3. %名前空間 ~SET %名前[ `namespace^l ]
    4. ~Assert: [ %名前 ~NEQ ε ]~AND[ %名前空間 ~NEQ ε ]
    5. ~IF[ %名前空間 ~EQ 空~文字列 ] ⇒ %名前空間 ~SET ~NULL
  3. ~RET «[ `name^l → %名前, `namespace^l → %名前空間 ]»
◎ To canonicalize a sanitizer name given a DOMString or dictionary name, and a default namespace defaultNamespace (default null): • If name is a DOMString, then return «[ "name" → name, "namespace" → defaultNamespace ]». • Assert: name is a dictionary and both name["name"] and name["namespace"] exist. • If name["namespace"] is the empty string, then set it to null. • Return «[ "name" → name["name"], "namespace" → name["namespace"] ]».
`無毒化器~用の要素を正準-化する@ ~algoは、 所与の ( `SanitizerElement$I %要素 ) に対し ⇒ ~RET `無毒化器~用の名前を正準-化する$( %要素, `~HTML名前空間$ ) ◎ To canonicalize a sanitizer element given a SanitizerElement element: • Return the result of canonicalizing element with the HTML namespace as the default namespace.

`無毒化器~用の要素~listを正準-化する@ ~algoは、 所与の ( %~list ) に対し: ◎ To canonicalize a sanitizer element list list:

  1. %新たな~list ~LET « » ◎ Let newList be « ».
  2. %~list を成す ~EACH( %~item ) に対し ⇒ %新たな~list に次の結果を`付加する$ ⇒ `無毒化器~用の要素を正準-化する$( %~item ) ◎ For each item in list, append the result of canonicalizing item to newList.
  3. ~RET %新たな~list ◎ Return newList.

`正準-化された交差集合@ を見出す~algoは、 所与の ( `~list$ %~A, `~list$ %~B ) に対し: ◎ To find the canonicalized intersection of lists A and B:

  1. %集合~A ~LET « » ◎ Let setA be « ».
  2. %集合~B ~LET « » ◎ Let setB be « ».
  3. %~A を成す ~EACH( %~item【!entry】 ) に対し ⇒ %集合~A に次の結果を`付加する$set ⇒ `無毒化器~用の名前を正準-化する$( %~item【!entry】 ) ◎ For each entry of A, append the result of canonicalizing entry to setA.
  4. %~B を成す ~EACH( %~item【!entry】 ) に対し ⇒ %集合~B に次の結果を`付加する$set ⇒ `無毒化器~用の名前を正準-化する$( %~item【!entry】 ) ◎ For each entry of B, append the result of canonicalizing entry to setB.
  5. ~RET `交差集合$`名前$sub( %集合~A, %集合~B ) ◎ Return the intersection of setA and setB.

`get()@m ~method手続きは: ◎ The get() method steps are:

注記: この~methodの外側からは、 当の `Sanitizer$I の`環境設定$を成す[ 要素たち/属性たち ]の順序は,観測-不能である。 この~methodの結果において,それらが明示的に~sortされるわけは、 実装に — 例えば,内部的には無順序~集合を利用することにより — 最適化する機会を与えるためである。 ◎ Outside of the get() method, the order of the Sanitizer's elements and attributes is unobservable. By explicitly sorting the result of this method, we give implementations the opportunity to optimize by, for example, using unordered sets internally.

  1. %環境設定 ~LET コレの`環境設定$ ◎ Let config be this's configuration.
  2. ~Assert: %環境設定 は`妥当$である。 ◎ Assert: config is valid.
  3. « "`elements$mb", "`removeElements$mb", `replaceWithChildrenElements$mb", "`attributes$mb", "`removeAttributes$mb" » を成す ~EACH( %~key ) に対し:

    1. %~list ~LET %環境設定[ %~key ]
    2. ~IF[ %~list ~EQ ε ] ⇒ ~CONTINUE
    3. %環境設定[ %~key ] ~SET `~listを昇順に~sortする$( %~list, `無毒化器~itemを比較する$ )
    4. ~IF[ %~key ~NEQ "`elements$mb" ] ⇒ ~CONTINUE
    5. %~list を成す ~EACH( %要素 ) に対し:

      1. « "`attributes$mbE", `removeAttributes$mbE » を成す ~EACH( %属性~key ) に対し:

        1. %属性~群 ~LET %要素[ %属性~key ]
        2. ~IF[ %属性~群 ~EQ ε ] ⇒ ~CONTINUE
        3. %要素[ %属性~key ] ~SET `~listを昇順に~sortする$( %要素[ %~key~A ], `無毒化器~itemを比較する$ )
    ◎ If config["elements"] exists: • For each element of config["elements"]: •• If element["attributes"] exists, then set element["attributes"] to the result of sorting element["attributes"], with compare sanitizer items. •• If element["removeAttributes"] exists, then set element["removeAttributes"] to the result of sorting element["removeAttributes"], with compare sanitizer items. • Set config["elements"] to the result of sorting config["elements"], with compare sanitizer items. ◎ Otherwise: ◎ • Set config["removeElements"] to the result of sorting config["removeElements"], with compare sanitizer items. ◎ If config["replaceWithChildrenElements"] exists, then set config["replaceWithChildrenElements"] to the result of sorting config["replaceWithChildrenElements"], with compare sanitizer items. ◎ If config["processingInstructions"] exists, then set config["processingInstructions"] to the result of sorting config["processingInstructions"], with piA["target"] being code unit less than piB["target"]. ◎ Otherwise: • Set config["removeProcessingInstructions"] to the result of sorting config["removeProcessingInstructions"], with piA["target"] being code unit less than piB["target"]. ◎ If config["attributes"] exists, then set config["attributes"] to the result of sorting config["attributes"] given compare sanitizer items. ◎ Otherwise: • Set config["removeAttributes"] to the result of sorting config["removeAttributes"] given compare sanitizer items.
  4. %~targetどうしを比較する ~LET 次の手続き

    手続きは、 所与の ( %~pi~A, %~pi~B ) に対し ⇒ ~RET %~pi~A[ "`target$mb" ] は %~pi~B[ "`target$mb" ] `未満の符号単位~列$である
    ◎ ↑
  5. « "`processingInstructions$mb", "`removeProcessingInstructions$mb" » を成す ~EACH( %~key ) に対し:

    1. %~list ~LET %環境設定[ %~key ]
    2. ~IF[ %~list ~EQ ε ] ⇒ ~CONTINUE
    3. %環境設定[ %~key ] ~SET `~listを昇順に~sortする$( %~list, %~targetどうしを比較する )
    ◎ ↑
  6. ~RET %環境設定 ◎ Return config.

`allowElement(element)@m ~method手続きは: ◎ The allowElement(element) method steps are:

  1. %環境設定 ~LET コレの`環境設定$ ◎ Let configuration be this's configuration.
  2. ~Assert: %環境設定 は`妥当$である。 ◎ Assert: configuration is valid.
  3. %element ~SET `属性~群を伴う無毒化器~要素を正準-化する$( %element ) ◎ Set element to the result of canonicalizing element.
  4. ~IF[ %環境設定[ "`elements$mb" ] ~NEQ ε ]: ◎ If configuration["elements"] exists:

    1. %改変されたか ~LET %環境設定[ "`replaceWithChildrenElements$mb" ] から %element と`同等な名前$を`除去する$ ◎ Let modified be the result of removing element from configuration["replaceWithChildrenElements"].
    2. ~IF[ %環境設定[ "`attributes$mb" ] ~NEQ ε ]: ◎ If configuration["attributes"] exists:

      1. ~IF[ %element[ "`attributes$mbE" ] ~NEQ ε ]: ◎ If element["attributes"] exists:

        1. %element[ "`attributes$mbE" ] ~SET `差集合$`名前$sub( `~listから集合を作成する$`名前$sub( %element[ "`attributes$mbE" ] ), %環境設定[ "`attributes$mb" ] ) ◎ Set element["attributes"] to the result of creating a set from element["attributes"]. ◎ Set element["attributes"] to the difference of element["attributes"] and configuration["attributes"].
        2. ~IF[ %環境設定[ "`dataAttributes$mb" ] ~EQ ~T ] ⇒ %element[ "`attributes$mbE" ] から次を満たす~itemを`除去する$ ⇒ ある`~custom~data属性$と`同等な名前$である ◎ If configuration["dataAttributes"] is true, then remove all items item from element["attributes"] where item is a custom data attribute.
      2. ~IF[ %element[ "`removeAttributes$mbE" ] ~NEQ ε ] ⇒ %element[ "`removeAttributes$mbE" ] ~SET `交差集合$`名前$sub【!`正準-化された交差集合$】( `~listから集合を作成する$`名前$sub( %element[ "`removeAttributes$mbE" ] ), %環境設定[ "`attributes$mb" ] ) ◎ If element["removeAttributes"] exists: • Set element["removeAttributes"] to the result of creating a set from element["removeAttributes"]. • Set element["removeAttributes"] to the intersection of element["removeAttributes"] and configuration["attributes"].
    3. ~ELSE: ◎ Otherwise:

      1. ~IF[ %element[ "`attributes$mbE" ] ~NEQ ε ]: ◎ If element["attributes"] exists:

        1. %element[ "`attributes$mbE" ] ~SET `差集合$`名前$sub( `~listから集合を作成する$`名前$sub( %element[ "`removeAttributes$mbE" ] ), %element[ "`removeAttributes$mbE" ] ~DF « » ) ◎ Set element["attributes"] to the result of creating a set from element["attributes"]. ◎ Set element["attributes"] to the difference of element["attributes"] and element["removeAttributes"] with default « ».
        2. %element[ "`removeAttributes$mbE" ] ~SET ε ◎ Remove element["removeAttributes"].
        3. %element[ "`attributes$mbE" ] ~SET `差集合$`名前$sub( %element[ "`attributes$mbE" ], %環境設定[ "`removeAttributes$mb" ] ) ◎ Set element["attributes"] to the difference of element["attributes"] and configuration["removeAttributes"].
      2. ~IF[ %element[ "`removeAttributes$mbE" ] ~NEQ ε ] ⇒ %element[ "`removeAttributes$mbE" ] ~SET `差集合$`名前$sub( `~listから集合を作成する$`名前$sub( %element[ "`removeAttributes$mbE" ] ), %環境設定[ "`removeAttributes$mb" ] ) ◎ If element["removeAttributes"] exists: • Set element["removeAttributes"] to the result of creating a set from element["removeAttributes"]. • Set element["removeAttributes"] to the difference of element["removeAttributes"] and configuration["removeAttributes"].
    4. %現在の要素 ~LET `~listから同等な名前を見出す$( %環境設定[ "`elements$mb" ], %element ) ◎ ↓
    5. ~IF[ %現在の要素 ~EQ ε ]: ◎ If configuration["elements"] does not contain element:

      1. %環境設定[ "`elements$mb" ] に %element を`付加する$ ◎ Append element to configuration["elements"].
      2. ~RET ~T ◎ Return true.
    6. ~IF[ %element は %現在の要素 に等しい ] ⇒ ~RET %改変されたか

      【 この比較は、 きちんと定義されていない。 [ %element ~EQ`名前$sub %現在の要素 ]が満たされることは判っているので、 実際には、 各 %~key ~IN { "`attributes$mbE", "`removeAttributes$mbE" } に対し, ~OR↓ が満たされることを意味するであろう: 】

      • ~AND↓:

        • %element[ %~key ] ~EQ ε
        • %現在の要素[ %~key ] ~EQ ε
      • ~AND↓:

        • %element[ %~key ] ~NEQ ε
        • %現在の要素[ %~key ] ~NEQ ε
        • ( %element[ %~key ], %現在の要素[ %~key ] ) は`同等な集合$`名前$subである

          ( “同等な集合” は`有順序~集合$用に定義される演算であるが、 重複は無いことは判っているので,集合と見做せる。)

      ◎ ↑ Let currentElement be the item in configuration["elements"] whose name member is element's name member and whose namespace member is element's namespace member. ◎ If element is equal to currentElement, then return modified.
    7. %環境設定[ "`elements$mb" ] から %element と`同等な名前$を`除去する$ ◎ Remove element from configuration["elements"].
    8. %環境設定[ "`elements$mb" ] に %element を`付加する$ ◎ Append element to configuration["elements"].
    9. ~RET ~T ◎ Return true.
  5. ~ELSE: ◎ Otherwise:

    1. ~IF[ %element[ "`attributes$mbE" ] ~NEQ ε ]~OR[ %element[ "`removeAttributes$mbE" ] ~DF « » は`空$でない ] ⇒ ~RET ~F ◎ If element["attributes"] exists or element["removeAttributes"] with default « » is not empty, then return false.
    2. %改変されたか ~LET %環境設定[ "`replaceWithChildrenElements$mb" ] から %element と`同等な名前$を`除去する$ ◎ Let modified be the result of removing element from configuration["replaceWithChildrenElements"].
    3. ~IF[ %element ~NIN`名前$sub %環境設定[ "`removeElements$mb" ] ] ⇒ ~RET %改変されたか ◎ If configuration["removeElements"] does not contain element, then return modified.
    4. %環境設定[ "`removeElements$mb" ] から %element と`同等な名前$を`除去する$ ◎ Remove element from configuration["removeElements"].
    5. ~RET ~T ◎ Return true.

`removeElement(element)@m ~method手続きは ⇒ ~RET `要素を除去するよう環境設定する$( コレの`環境設定$, %element ) ◎ The removeElement(element) method steps are to return the result of removing element from this's configuration.

`replaceElementWithChildren(element)@m ~method手続きは: ◎ The replaceElementWithChildren(element) method steps are:

  1. %環境設定 ~LET コレの`環境設定$ ◎ Let configuration be this's configuration.
  2. ~Assert: %環境設定 は`妥当$である。 ◎ Assert: configuration is valid.
  3. %element ~SET `無毒化器~用の要素を正準-化する$( %element ) ◎ Set element to the result of canonicalizing element.
  4. ~IF[ %element ~IN`名前$sub `組込みの置換-可能でない要素~list$ ] ⇒ ~RET ~F ◎ If the built-in non-replaceable elements list contains element, then return false.
  5. %結果 ~LET ~F ◎ ↓
  6. « "`elements$mb", "`removeElements$mb" » を成す ~EACH( %~key ) に対し:

    1. %改変されたか ~LET %環境設定[ %~key ] から %element と`同等な名前$を`除去する$
    2. ~IF[ %改変されたか ~EQ ~T ] ⇒ %結果 ~SET ~T
    ◎ Let modified be the result of removing element from configuration["elements"]. ◎ If removing element from configuration["removeElements"]\ ◎ is true, then set modified to true.
  7. ~IF[ %element ~NIN`名前$sub %環境設定[ "`replaceWithChildrenElements$mb" ] ]: ◎ If configuration["replaceWithChildrenElements"] does not contain element:

    1. %環境設定[ "`replaceWithChildrenElements$mb" ] に %element を`付加する$ ◎ Append element to configuration["replaceWithChildrenElements"].
    2. ~RET ~T ◎ Return true.
  8. ~RET %結果 ◎ Return modified.

`allowAttribute(attribute)@m ~method手続きは: ◎ The allowAttribute(attribute) method steps are:

  1. %環境設定 ~LET コレの`環境設定$ ◎ Let configuration be this's configuration.
  2. ~Assert: %環境設定 は`妥当$である。 ◎ Assert: configuration is valid.
  3. %attribute ~SET `無毒化器~用の名前を正準-化する$( %attribute ) ◎ Set attribute to the result of canonicalizing attribute.
  4. ~IF[ %環境設定[ "`attributes$mb" ] ~NEQ ε ]: ◎ If configuration["attributes"] exists:

    1. ~IF[ %環境設定[ "`dataAttributes$mb" ] ~EQ ~T ]~AND[ %attribute は`~custom~data属性$である ] ⇒ ~RET ~F ◎ If configuration["dataAttributes"] is true and attribute is a custom data attribute, then return false.
    2. ~IF[ %attribute ~IN`名前$sub %環境設定[ "`attributes$mb" ] ] ⇒ ~RET ~F ◎ If configuration["attributes"] contains attribute, then return false.
    3. ~IF[ %環境設定[ "`elements$mb" ] ~NEQ ε ] ⇒ %環境設定[ "`elements$mb" ] を成す ~EACH( %要素 ) に対し ⇒ ~IF[ %attribute ~IN`名前$sub %要素[ "`attributes$mbE" ] ~DF « » ] ⇒ %要素[ "`attributes$mbE" ] から %attribute と`同等な名前$を`除去する$ ◎ If configuration["elements"] exists: • For each element in configuration["elements"]: •• If element["attributes"] with default « » contains attribute, then remove attribute from element["attributes"].
    4. %環境設定[ "`attributes$mb" ] に %attribute を`付加する$ ◎ Append attribute to configuration["attributes"].
    5. ~RET ~T ◎ Return true.
  5. ~ELSE ⇒ ~RET %環境設定[ "`removeAttributes$mb" ] から %attribute と`同等な名前$を`除去する$ ◎ Otherwise: • If configuration["removeAttributes"] does not contain attribute, then return false. • Remove attribute from configuration["removeAttributes"]. • Return true.

`removeAttribute(attribute)@m ~method手続きは ⇒ ~RET `属性を除去するよう環境設定する$( コレの`環境設定$, %attribute ) ◎ The removeAttribute(attribute) method steps are to return the result of removing attribute from this's configuration.

`setComments(allow)@m ~method手続きは: ◎ The setComments(allow) method steps are:

  1. %環境設定 ~LET コレの`環境設定$ ◎ Let configuration be this's configuration.
  2. ~Assert: %環境設定 は`妥当$である。 ◎ Assert: configuration is valid.
  3. %結果 ~LET ~IS[ %環境設定[ "`comments$mb" ] ~NEQ %allow ] ◎ ↓
  4. %環境設定[ "`comments$mb" ] ~SET %allow ◎ ↓
  5. ~RET %結果 ◎ If configuration["comments"] exists and is equal to allow, then return false. ◎ Set configuration["comments"] to allow. ◎ Return true.

`setDataAttributes(allow)@m ~method手続きは: ◎ The setDataAttributes(allow) method steps are:

  1. %環境設定 ~LET コレの`環境設定$ ◎ Let configuration be this's configuration.
  2. ~Assert: %環境設定 は`妥当$である。 ◎ Assert: configuration is valid.
  3. ~IF[ %環境設定[ "`attributes$mb" ] ~EQ ε ] ⇒ ~RET ~F ◎ If configuration["attributes"] does not exist, then return false.
  4. ~IF[ %環境設定[ "`dataAttributes$mb" ] ~EQ %allow ] ⇒ ~RET ~F ◎ If configuration["dataAttributes"] exists and is equal to allow, then return false.
  5. ~IF[ %allow ~EQ ~T ]: ◎ If allow is true:

    1. ~IF[ %環境設定[ "`elements$mb" ] ~NEQ ε ] ⇒ %環境設定[ "`elements$mb" ] を成す ~EACH( %要素 ) に対し ⇒ ~IF[ %要素[ "`attributes$mbE" ] ~NEQ ε ] ⇒ %要素[ "`attributes$mbE" ] から次を満たす~itemを`除去する$ ⇒ ある`~custom~data属性$と`同等な名前$である ◎ If configuration["elements"] exists: • For each element of configuration["elements"]: •• If element["attributes"] exists, then remove all items item from element["attributes"] where item is a custom data attribute.
    2. %環境設定[ "`attributes$mb" ] から 次を満たす~itemを`除去する$ ⇒ ある`~custom~data属性$と`同等な名前$である ◎ Remove all items item from configuration["attributes"] where item is a custom data attribute.
  6. %環境設定[ "`dataAttributes$mb" ] ~SET %allow ◎ Set configuration["dataAttributes"] to allow.
  7. ~RET ~T ◎ Return true.

`allowProcessingInstruction(pi)@m ~method手続きは: ◎ The allowProcessingInstruction(pi) method steps are:

  1. %環境設定 ~LET コレの`環境設定$ ◎ Let configuration be this's configuration.
  2. ~Assert: %環境設定 は`妥当$である。 ◎ Assert: configuration is valid.
  3. %pi ~SET `無毒化器~用の処理命令を正準-化する$( %pi ) ◎ Set pi to the result of canonicalizing pi.
  4. ~IF[ %環境設定[ "`processingInstructions$mb" ] ~NEQ ε ]: ◎ If configuration["processingInstructions"] exists:

    1. ~IF[ %pi ~IN`~target$sub %環境設定[ "`processingInstructions$mb" ] ] ⇒ ~RET ~F ◎ If configuration["processingInstructions"] contains pi, then return false.
    2. %環境設定[ "`processingInstructions$mb" ] に %pi を`付加する$ ◎ Append pi to configuration["processingInstructions"].
    3. ~RET ~T ◎ Return true.
  5. ~RET %環境設定[ "`removeProcessingInstructions$mb" ] から %pi と`同等な~target$を`除去する$ ◎ Otherwise: • If configuration["removeProcessingInstructions"] contains pi: •• Remove pi from configuration["removeProcessingInstructions"]. •• Return true. • Return false.

`removeProcessingInstruction(pi)@m ~method手続きは: ◎ The removeProcessingInstruction(pi) method steps are:

  1. %環境設定 ~LET コレの`環境設定$ ◎ Let configuration be this's configuration.
  2. ~Assert: %環境設定 は`妥当$である。 ◎ Assert: configuration is valid.
  3. %pi ~SET `無毒化器~用の処理命令を正準-化する$( %pi ) ◎ Set pi to the result of canonicalizing pi.
  4. ~IF[ %環境設定[ "`processingInstructions$mb" ] ~NEQ ε ] ⇒ ~RET %環境設定[ "`processingInstructions$mb" ] から %pi と`同等な~target$を`除去する$ ◎ If configuration["processingInstructions"] exists: • If configuration["processingInstructions"] contains pi: •• Remove pi from configuration["processingInstructions"]. •• Return true. • Return false.
  5. ~IF[ %pi ~IN`~target$sub %環境設定[ "`removeProcessingInstructions$mb" ] ] ⇒ ~RET ~F ◎ Otherwise: • If configuration["removeProcessingInstructions"] contains pi, then return false.
  6. %環境設定[ "`removeProcessingInstructions$mb" ] に %pi を`付加する$ ◎ • Append pi to configuration["removeProcessingInstructions"].
  7. ~RET ~T ◎ • Return true.
`removeUnsafe()@m ~method手続きは ⇒ ~RET `安全でないものを除去するよう環境設定する$( コレの`環境設定$ ) ◎ The removeUnsafe() method steps are to return the result of removing unsafe from this's configuration.

8.6.3. 無毒化器の環境設定

dictionary `SanitizerElementNamespace@I {
  required DOMString `name@mbE;
  DOMString? _`namespace@mbE = "http://www.w3.org/1999/xhtml";
};

/* 
`elements$mb ~memberにより利用される:
◎
Used by "elements"
 */
dictionary `SanitizerElementNamespaceWithAttributes@I : `SanitizerElementNamespace$I {
  sequence<`SanitizerAttribute$I> `attributes@mbE;
  sequence<`SanitizerAttribute$I> `removeAttributes@mbE;
};

dictionary `SanitizerAttributeNamespace@I {
  required DOMString `name@mbA;
  DOMString? _`namespace@mbA = null;
};

dictionary `SanitizerProcessingInstruction@I {
  required DOMString `target@mb;
};

typedef (DOMString or `SanitizerElementNamespace$I) `SanitizerElement@I;
typedef (DOMString or `SanitizerElementNamespaceWithAttributes$I) `SanitizerElementWithAttributes@I;
typedef (DOMString or `SanitizerProcessingInstruction$I) `SanitizerPI@I;
typedef (DOMString or `SanitizerAttributeNamespace$I) `SanitizerAttribute@I;

dictionary `SanitizerConfig@I {
  sequence<`SanitizerElementWithAttributes$I> `elements@mb;
  sequence<`SanitizerElement$I> `removeElements@mb;
  sequence<`SanitizerElement$I> `replaceWithChildrenElements@mb;

  sequence<`SanitizerPI$I> `processingInstructions@mb;
  sequence<`SanitizerPI$I> `removeProcessingInstructions@mb;

  sequence<`SanitizerAttribute$I> `attributes@mb;
  sequence<`SanitizerAttribute$I> `removeAttributes@mb;

  boolean `comments@mb;
  boolean `dataAttributes@mb;
};

次に挙げる 辞書どうしは、 それを成すすべての~memberどうしが等しいとき,等しいものと見なされる。 ⇒# `SanitizerElementNamespace$I / `SanitizerAttributeNamespace$I / `SanitizerElementNamespaceWithAttributes$I / `SanitizerProcessingInstruction$I ◎ SanitizerElementNamespace, SanitizerAttributeNamespace, SanitizerElementNamespaceWithAttributes, and SanitizerProcessingInstruction dictionaries are considered equal when all of their members are equal.

同等性は、 代わりに `INFRA$r 仕様~内に定義されるべきである。 その仕様の `課題 #664@https://github.com/whatwg/infra/issues/664$ を見よ。 【`§ 無毒化器~itemどうしの同等性@#_equality-of-sanitizer-items$も見よ。】 ◎ Equality should be defined in the infra spec instead. See issue #664.

8.6.3.X. 無毒化器~itemどうしの同等性

【 この節は、 明確化するための,この訳による追加。 】

正準的な`環境設定$ (`環境設定を正準-化する$~algoを経たもの) を成す~list~member( `sequence^c 型の~member) を成し得る~itemどうしの同等性は、 以下に定義される。 (それらの~listに適用される`~list$用の演算(例:~IN)は,それに基づくことになる)。

`正準的な名前@ とは、 ~AND↓ を満たす`有順序~map$ %~map である:

  • %~map[ `name^l ] は文字列である
  • %~map[ `namespace^l ] は[ 文字列/ ~NULL ]である

(`無毒化器~用の名前を正準-化する$~algoを経た無毒化器~itemは、 `正準的な名前$になる。)

所与の ( `正準的な名前$ %A, `正準的な名前$ %B ) が `同等な名前@ であるとは、 ~AND↓ が満たされることをいう:

  • %A[ `name^l ] ~EQ %B[ `name^l ]
  • %A[ `namespace^l ] ~EQ %B[ `namespace^l ]

この条件は、 “ %A ~EQ`名前$sub %B ” とも表記される。 ~EQ に代えて[ ~NEQ / ~IN ]と伴に利用された場合や同等性に依拠する演算(例:`差集合$)に付記された場合も、 それらの定義は,この同等性に基づくことになる。

`~listから同等な名前を見出す@ ~algoは、 所与の ( %~list, %名前 ) に対し:

  1. %~list を成す ~EACH( %~item ) に対し ⇒ ~IF[ %~item ~EQ`名前$sub %名前 ] ⇒ ~RET %~item
  2. ~RET ε

`正準的な~target@ とは、 次を満たす`有順序~map$ %~map である ⇒ %~map[ `target^l ] は文字列である

所与の ( `正準的な~target$ %A, `正準的な~target$ %B ) が `同等な~target@ であるとは、 次が満たされることをいう ⇒ %A[ `target^l ] ~EQ %B[ `target^l ]

この条件は、 “ %A ~EQ`~target$sub %B ” とも表記される。 ~EQ に代えて[ ~NEQ / ~IN ]と伴に利用された場合も、 それらの定義は,この同等性に基づくことになる。

集合~用の演算(例:`差集合$ )に渡される`妥当$な`環境設定$を成す~list~memberは、 暗黙的に等価な`有順序~集合$と見なされる — それらの各~listに重複は無いことは、 検証-済みなので。

8.6.3.1. 環境設定の不変則
◎非規範的

`環境設定$は、 開発者により,自身の目的に適するよう改変-[ できる/されるべき ]である。 次に挙げる~optionがある: ◎ Configurations can and ought to be modified by developers to suit their purposes. Options are\

  • 新たな `SanitizerConfig$I 辞書を一から書く。 ◎ to write a new SanitizerConfig dictionary from scratch,\
  • 既存の `Sanitizer$I の`環境設定$を各種~改変子~methodを利用して改変する。 ◎ to modify an existing Sanitizer's configuration by using the modifier methods, or\
  • 既存の `Sanitizer$I の`環境設定$を `get()$m により辞書として取得して, それを改変した結果で新たな `Sanitizer$I を作成する。 ◎ to get() an existing Sanitizer's configuration as a dictionary and modify the dictionary and then create a new Sanitizer with it.

空な環境設定は、 あらゆるものを許容する ( `setHTMLUnsafe()$m の様な “安全でない” ~methodで~callされたとき)。 環境設定 `default@l は、 `組込みの安全な既定の環境設定$を包含する。 各種 無毒化器~method用の既定の環境設定は、[ “安全な” ~method, “安全でない” ~method ]で異なることに注意。 ◎ An empty configuration allows everything (when called with the "unsafe" methods like setHTMLUnsafe()). A configuration "default" contains a built-in safe default configuration. Note that "safe" and "unsafe" sanitizer methods have different defaults.

環境設定~辞書は妥当になるとは限らない。 妥当な環境設定は、 冗長性(例:同じ要素を許容されるものとして重ねて指定すること)や 矛盾(例:同じ要素を[ 除去されるもの, 許容されるもの ]として同時に指定すること)を避ける。 ◎ Not all configuration dictionaries are valid. A valid configuration avoids redundancy (like specifying the same element to be allowed twice) and contradictions (like specifying an element to be both removed and allowed.)

環境設定が妥当になるためには、 以下に挙げる条件を満たす必要がある: ◎ Several conditions need to hold for a configuration to be valid:

  • 大域的な[ 許容-~list, 除去-~list ]の混在 ◎ Mixing global allow- and remove-lists:

    【 “大域的” とは、 すべての要素にわたって大域的である — すなわち, `SanitizerConfig$I の~memberである — ことを意味する。 対して, “局所的” とは、 ある要素に局所的である — すなわち, `SanitizerElementNamespaceWithAttributes$I の~memberである — ことを意味する。 】

    • [ `elements$mb, `removeElements$mb ]は片方しか在り得ない。 どちらも欠落な場合、 `removeElements$mb は空な~listであることと等価になる。 ◎ elements or removeElements can exist, but not both. If both are missing, this is equivalent to removeElements being an empty list.
    • [ `attributes$mb, `removeAttributes$mb ]は片方しか在り得ない。 どちらも欠落な場合、 `removeAttributes$mb が空な~listであることと等価になる。 ◎ attributes or removeAttributes can exist, but not both. If both are missing, this is equivalent to removeAttributes being an empty list.
    • `dataAttributes$mb は、 概念的には,許容-~list `attributes$mb の拡張を成す。 `dataAttributes$mb ~memberが ~T になるのは、 `attributes$mb ~memberが在る場合【!~listが利用されるとき】に限り許容される。 ◎ dataAttributes is conceptually an extension of the attributes allow-list. The dataAttributes member is only allowed when an attributes list is used.
  • 異なる大域的な~listどうしにおける重複な~item【!entry】 【`同等な名前$を成す~itemたち(以下同様)】: ◎ Duplicate entries between different global lists:

    • 次に挙げる~listどうしには,重複な~item【!entry】は無い (すなわち,同じ要素は無い) ⇒# `elements$mb, `removeElements$mb, `replaceWithChildrenElements$mb ◎ There are no duplicate entries (i.e., no same elements) between elements, removeElements, or replaceWithChildrenElements.
    • 次に挙げる~listどうしには,重複な~item【!entry】は無い (すなわち,同じ属性は無い) ⇒# `attributes$mb, `removeAttributes$mb

      【 これらは,片方しか在り得ないはずなので、 この記述はイミを成さないように見えるが? 】

      ◎ There are no duplicate entries (i.e., no same attributes) between attributes or removeAttributes.
  • 各~要素に局所的な[ 許容-~list, 除去-~list ]の混在: ◎ Mixing local allow- and remove-lists on the same element:

    • 大域的な~list `attributes$mb が在るときは、 同じ要素に局所的な~list[ `attributes$mbE, `removeAttributes$mbE ]のうち,片方に限り許容される。 ◎ When an attributes list exists, both, either or none of the attributes and removeAttributes lists are allowed on the same element.
    • 大域的な~list `removeAttributes$mb が在るときは、 同じ要素に局所的な~list[ `attributes$mbE, `removeAttributes$mbE ]のうち,片方に限り許容される。 ◎ When a removeAttributes list exists, either or none of the attributes and removeAttributes lists are allowed on the same element, but not both.
  • 同じ要素~上の重複な~item【!entry】: ◎ Duplicate entries on the same element:

    • 同じ要素~上の[ `attributes$mbE, `removeAttributes$mbE ]どうしには,重複な~item【!entry】は無い。 ◎ There are no duplicate entries between attributes and removeAttributes on the same element.
  • `replaceWithChildrenElements$mb 内には `組込みの置換-可能でない要素~list$を成す要素は現れない — これらの各~要素を その子~群で置換することは、[ 構文解析し直す課題/無効な~node~tree ]へ至らせ得るので。 ◎ No element from the built-in non-replaceable elements list appears in replaceWithChildrenElements, since replacing these elements with their children could lead to re-parsing issues or invalid node trees.

要素~用の許容-~list `elements$mb は、 それを成す各~要素~用に局所的な[ 許容する属性【 `attributes$mbE 】/ 除去する属性【 `removeAttributes$mbE 】 ]も指定し得る。 これは、 この標準の構造 — [ `大域的な属性@~HTMLdom#global-attributes$/ 特定の要素に局所的に適用される属性 ]どちらも知る構造 — を~~反映することが意味される。 [ 大域的な属性, 局所的な属性 ]は,混在し得るが、 特定0の属性が[ 一方の~listにより許容され, 他方の~listにより禁止される ]ような多義的な環境設定は,一般に妥当でないことに注意。 ◎ The elements element allow-list can also specify allowing or removing attributes for a given element. This is meant to mirror this standard's structure, which knows both global attributes as well as local attributes that apply to a specific element. Global and local attributes can be mixed, but note that ambiguous configurations where a particular attribute would be allowed by one list and forbidden by another, are generally invalid.

大域的な `attributes$mb, 局所的な `attributes$mbE が在るとき
属性は、 どちらかの~list内に在る【!matches】ならば,許容される。
これらの~listどうしには,重複は許容されない。
大域的な `attributes$mb, 局所的な `removeAttributes$mbE が在るとき
属性は、[ 大域的な許容-~list内に在る ]かつ[ 局所的な除去-~list内には無い ]ならば,許容される。
局所的な除去-~listは、 大域的な許容-~listの下位集合になる必要がある。 (双方の~listどうしで重複な~item【!entry】が許容されるのは、 この場合に限られることに注意されたし。)
大域的な `removeAttributes$mb, 局所的な `attributes$mbE が在るとき
属性は、 局所的な許容-~list内に在る場合に限り,許容される。
これらの~listどうしには,重複な~item【!entry】は許容されない。
大域的な除去-~listは、 この特定0の要素~用には機能しないが, 他の要素のうち局所的な許容-~listを有するものには適用され得ることに注意。
大域的な `removeAttributes$mb, 局所的な `removeAttributes$mbE が在るとき
属性は、 どちらの~list内にも無いならば,許容される。
これらの~listどうしには,重複な~item【!entry】は許容されない。
◎ |global attributes|global removeAttributes local attributes|An attribute is allowed if it matches either list. No duplicates are allowed.|An attribute is only allowed if it's in the local allow list. No duplicate entries between global remove and local allow lists are allowed. Note that the global remove list has no function for this particular element, but can apply to other elements that do not have a local allow list. local removeAttributes|An attribute is allowed if it's in the global allow-list, but not in the local remove-list. Local remove has to be a subset of the global allow lists.|An attribute is allowed if it is in neither list. No duplicate entries between global remove and local remove lists are allowed. ◎ Please note the asymmetry where mostly no duplicates between global and per-element lists are permitted, but in the case of a global allow-list and a per-element remove-list the latter has to be a subset of the former. An excerpt of the table above, only focusing on duplicates, is as follows: ◎ |global attributes|global removeAttributes local attributes|No duplicates are allowed.|No duplicates are allowed. local removeAttributes|Local remove has to be a subset of the global allow lists.|No duplicates are allowed.

`dataAttributes$mb は、 許容-~listに対する拡張を成すものと見なせる — すなわち, ~T に設定された下では:

  • 大域的な許容-~list `attributes$mb が在る必要があり、 それが,あらゆる`~custom~data属性$を包含しているかのようにふるまう。 `~custom~data属性$は、 この~list内には在り得ない — さもなければ、 重複な~item【!entry】を意味することになるので。
  • 局所的な `attributes$mbE が在るときは、 すべての`~custom~data属性$が許容される。 `~custom~data属性$は、 この許容-~list内にも在り得ない — さもなければ、 重複な~item【!entry】を意味することになるので。
  • 局所的な `removeAttributes$mbE が在るときは、 `~custom~data属性$は、 この除去-~list内に無い場合に限り,許容される。
◎ The dataAttributes setting allows custom data attributes. The rules above easily extends to custom data attributes if one considers dataAttributes to be an allow-list: ◎ |global attributes and dataAttributes set local attributes|All custom data attributes are allowed. No custom data attributes can be listed in any allow-list, as that would mean a duplicate entry. local removeAttributes|A custom data attribute is allowed, unless it's listed in the local remove-list. No custom data attribute can be listed in the global allow-list, as that would mean a duplicate entry.

これらの規則を~~要約すると: ◎ Putting these rules in words:

  • [ 大域的な~list, 局所的な~list ]どうしの重複と相互作用: ◎ Duplicates and interactions between global and local lists:

    • 大域的な許容-~list `attributes$mb が在る場合、 どの要素においても: ◎ If a global attributes allow list exists, then all element's local lists:

      • 局所的な許容-~list `attributes$mbE が在る場合、 これらの~listどうしには,重複な~item【!entry】は在り得ない。 ◎ If a local attributes allow list exists, there can be no duplicate entries between these lists.
      • 局所的な除去-~list `removeAttributes$mbE が在る場合、 それを成す すべての~item【!entry】が, 大域的な許容-~list `attributes$mb 内にも在る必要がある。 ◎ If a local removeAttributes remove list exists, then all its entries also need to be listed in the global attributes allow list.
      • `dataAttributes$mb ~EQ ~T の場合、 `~custom~data属性$は,どちらの許容-~list内にも在り得ない。 ◎ If dataAttributes is true, then no custom data attributes can be listed in any of the allow-lists.
    • 大域的な除去-~list `removeAttributes$mb が在る場合: ◎ If a global removeAttributes remove list exists:

      • 局所的な許容-~list `attributes$mbE が在る場合、 これらの~listどうしには,重複な~item【!entry】は在り得ない。 ◎ If a local attributes allow list exists, there can be no duplicate entries between these lists.
      • 局所的な除去-~list `removeAttributes$mbE が在る場合、 これらの~listどうしには,重複な~item【!entry】は在り得ない。 ◎ If a local removeAttributes remove list exists, there can be no duplicate entries between these lists.
      • [ 局所的な許容-~list `attributes$mbE, 局所的な除去-~list `removeAttributes$mbE ]が,どちらも在ることはない。 ◎ Not both a local attributes allow list and local removeAttributes remove list exists.
      • `dataAttributes$mb は ~F になる必要がある。 ◎ dataAttributes has to be false.

8.6.4. 無毒化~algo

`~HTMLを設定して~filterする@ ~algoは、 所与の ⇒# [`要素$/`文書片$] %~target, `要素$ %文脈~要素, `文字列$ %~HTML, 辞書 %~option群, 真偽値 %安全か ◎終 に対し: ◎ To set and filter HTML, given an Element or DocumentFragment target, an Element contextElement, a string html, a dictionary options, and a boolean safe:

  1. ~IF[ ~AND↓ ]… ◎ If all of the following are true:

    • %安全か ~EQ ~T ◎ safe;
    • %文脈~要素 の`局所~名$el ~EQ "`script$e" ◎ contextElement's local name is "script"; and
    • %文脈~要素 の`名前空間$el ~IN { `~HTML名前空間$, `~SVG名前空間$ } ◎ contextElement's namespace is the HTML namespace or the SVG namespace,

    …ならば ⇒ ~RET ◎ then return.

  2. %無毒化器 ~LET `~option群から無毒化器~instanceを取得する$( %~option群. %安全か ) ◎ Let sanitizer be the result of calling getting a sanitizer from options given safe.
  3. %~scripting~mode ~LET `不活$i ◎ Let scriptingMode be Inert.
  4. ~IF[ %~option群[ "`runScripts$mbU" ] ~EQ ~T ]: ◎ If options["runScripts"] is true:

    1. ~Assert: %安全か ~EQ ~F ◎ Assert: safe is false.
    2. %~scripting~mode ~SET `素片$i ◎ Set scriptingMode to Fragment.
  5. %新たな子~群 ~LET `~HTML素片の構文解析~algo$( %文脈~要素, %~HTML, ~T, %~scripting~mode ) ◎ Let newChildren be the result of parsing a fragment given contextElement, html, true, and scriptingMode.

    注記: %新たな子~群 内の~scriptは、 %~target の中へ挿入されたときに限り,実行されることになる。 ◎ Scripts in newChildren will only execute once inserted into target.

  6. %新たな子~群 ~LET `~HTML素片の構文解析~algo$( %文脈~要素, %~HTML, ~T ) ◎ Let newChildren be the result of parsing a fragment given contextElement, html, and true.
  7. %文書片 ~LET 新たな`文書片$ — その ⇒# `~node文書$ ~SET %文脈~要素 の`~node文書$ ◎ Let fragment be a new DocumentFragment whose node document is contextElement's node document.
  8. %新たな子~群 を成す ~EACH( %~node ) に対し ⇒ `~nodeを付加する$( %~node, %文書片 ) ◎ For each node in newChildren, append node to fragment.
  9. `~nodeを無毒化する$( %文書片, %無毒化器, %安全か ) ◎ Sanitize fragment given sanitizer and safe.
  10. `全~内容を~nodeで置換する$( %~target, %文書片 ) ◎ Replace all with fragment within target.

`~option群から無毒化器~instanceを取得する@ ~algoは、 所与の ( 辞書 %~option群, 真偽値 %安全か) に対し: ◎ To get a sanitizer instance from options from a dictionary options with a boolean safe:

  1. %無毒化器~指定 ~LET %~option群[ "`sanitizer$mb" ] ~DF `default$l ◎ Let sanitizerSpec be "default". ◎ If options["sanitizer"] exists, then set sanitizerSpec to options["sanitizer"].
  2. ~IF[ %無毒化器~指定 は `Sanitizer$I ~objである ] ⇒ ~RET %無毒化器~指定 ◎ ↓
  3. ~Assert: %無毒化器~指定 は次に挙げるいずれかである ⇒# `SanitizerPresets$I ~member/ `SanitizerConfig$I 辞書 ◎ Assert: sanitizerSpec is either a Sanitizer instance, a SanitizerPresets member, or a SanitizerConfig dictionary.
  4. ~IF[ %無毒化器~指定 は文字列( `SanitizerPresets$I )である ]: ◎ If sanitizerSpec is a string:

    1. ~Assert: %無毒化器~指定 ~EQ `default$l ◎ Assert: sanitizerSpec is "default".
    2. %無毒化器~指定 ~SET `組込みの安全な既定の環境設定$ ◎ Set sanitizerSpec to the built-in safe default configuration.
  5. %無毒化器 ~LET `新たな~obj$( `Sanitizer$I ) ◎ If sanitizerSpec is a dictionary: • Let sanitizer be a new Sanitizer object.
  6. %その他諸々を許容するか ~LET ~IS[ %安全か ~EQ ~F ] ◎ • Let allowCommentsAndDataAttributes be true if safe is false; false otherwise.
  7. `無毒化器を環境設定する$( %無毒化器, %無毒化器~指定, %その他諸々を許容するか ) ◎ • Configure sanitizer given sanitizerSpec and allowCommentsAndDataAttributes.
  8. ~RET %無毒化器 ◎ • Set sanitizerSpec to sanitizer. ◎ Return sanitizerSpec.

`~nodeを無毒化する@ ~algoは、 所与の ( `~node$ %~node, `Sanitizer$I %無毒化器, 真偽値 %安全か ) に対し: ◎ To sanitize a Node node with a Sanitizer sanitizer and a boolean safe:

  1. %環境設定 ~LET %無毒化器 の`環境設定$ ◎ Let configuration be sanitizer's configuration.
  2. ~Assert: %環境設定 は`妥当$である。 ◎ Assert: configuration is valid.
  3. ~IF[ %安全か ~EQ ~T ] ⇒ `安全でないものを除去するよう環境設定する$( %環境設定 ) ◎ If safe is true, then remove unsafe from configuration.
  4. `内縁な無毒化する手続き$( %~node, %環境設定, %安全か ) ◎ Run the inner sanitize steps given node, configuration, and safe.

`内縁な無毒化する手続き@ は、 所与の ( `~node$ %~node, `SanitizerConfig$I %環境設定, 真偽値 %~JS~navi~URLを取扱うか ) に対し: ◎ To perform the inner sanitize steps given a Node node, a SanitizerConfig configuration, and a boolean handleJavascriptNavigationUrls:

  1. %~node の`子~群$を成す ~EACH( %子 ) に対し: ◎ For each child of node's children:

    1. ~Assert: %子 は 次に挙げるいずれかの~nodeである ⇒# `Text$I, `Comment$I, `Element$I, `ProcessingInstruction$I, `DocumentType$I ◎ Assert: child is a Text, Comment, Element, ProcessingInstruction, or DocumentType node.
    2. ~IF[ %子 は[ `DocumentType$I / `Text$I ]~nodeである ] ⇒ ~CONTINUE ◎ If child is a DocumentType or Text node, then continue.
    3. ~IF[ %子 は `Comment$I ~nodeである ]: ◎ If child is a Comment node:

      1. ~IF[ %環境設定[ "`comments$mb" ] ~NEQ ~T ] ⇒ `~nodeを除去する$( %子 ) ◎ If configuration["comments"] is not true, then remove child.
      2. ~CONTINUE ◎ Continue.
    4. ~IF[ %子 は `ProcessingInstruction$I ~nodeである ]: ◎ If child is a ProcessingInstruction node:

      1. %~pi~target ~LET `無毒化器~用の処理命令を正準-化する$( %子 の`~target$pI ) ◎ Let piTarget be child's target.
      2. ~IF[ ~OR↓ ]…

        • %~pi~target ~NIN`~target$sub %環境設定[ "`processingInstructions$mb" ] ~DF « %~pi~target »
        • %~pi~target ~IN`~target$sub %環境設定[ "`removeProcessingInstructions$mb" ] ~DF « »

        …ならば:

        1. `~nodeを除去する$( %子 )
        2. ~CONTINUE
        ◎ If configuration["processingInstructions"] exists: • If configuration["processingInstructions"] does not contain piTarget, then remove child. ◎ Otherwise: • If configuration["removeProcessingInstructions"] contains piTarget, then remove child.
    5. ~ELSE: ◎ Otherwise:

      1. %要素~名 ~LET 新たな `SanitizerElementNamespace$I — その ⇒# `name$mbE ~SET %子 の`局所~名$el `namespace$mbE ~SET %子 の`名前空間$el ◎ Let elementName be a SanitizerElementNamespace with child's local name and namespace.
      2. ~IF[ %要素~名 ~IN`名前$sub %環境設定[ "`replaceWithChildrenElements$mb" ] ~DF « » ]: ◎ If configuration["replaceWithChildrenElements"] exists and configuration["replaceWithChildrenElements"] contains elementName:

        1. ~Assert: %~node は `Document$I でない。 ◎ Assert: node is not a Document.
        2. `内縁な無毒化する手続き$( %子, %環境設定, %~JS~navi~URLを取扱うか ) ◎ Run the inner sanitize steps given child, configuration, and handleJavascriptNavigationUrls.
        3. %文書片 ~LET 新たな`文書片$ — その ⇒# `~node文書$ ~SET %~node の`~node文書$ ◎ Let fragment be a new DocumentFragment whose node document is node's node document.
        4. %子 の`子~群$を成す ~EACH( %内縁な子 ) に対し ⇒ `~nodeを付加する$( %内縁な子, %文書片 ) ◎ For each innerChild of child's children, append innerChild to fragment.
        5. `子を~nodeで置換する$( %~node, %子, %文書片 ) ◎ Replace child with fragment within node.\

          ~Assert: この段は例外を投出しない。 ◎ Assert that this did not throw.

        6. ~CONTINUE ◎ Continue.
      3. ~IF[ ~OR↓ ]…

        • %要素~名 ~NIN`名前$sub %環境設定[ "`elements$mb" ] ~DF « %要素~名 »
        • %要素~名 ~IN`名前$sub %環境設定[ "`removeElements$mb" ] ~DF « »

        …ならば:

        1. `~nodeを除去する$( %子 )
        2. ~CONTINUE
        ◎ If configuration["elements"] exists: • If configuration["elements"] does not contain elementName, then remove child and continue. ◎ Otherwise: • If configuration["removeElements"] contains elementName, then remove child and continue.
      4. ~IF[ %要素~名[ "`name$mbE" ] ~EQ "`template$e" ]~AND[ %要素~名[ "`namespace$mbE" ] ~EQ `~HTML名前空間$ ] ⇒ `内縁な無毒化する手続き$( %子 の`~template内容$, %環境設定, %~JS~navi~URLを取扱うか ) ◎ If elementName["name"] is "template" and elementName["namespace"] is the HTML namespace, then run the inner sanitize steps given child's template contents, configuration, and handleJavascriptNavigationUrls.
      5. ~IF[ %子 は`~shadow~host$である ] ⇒ `内縁な無毒化する手続き$( %子 の`~shadow根$, %環境設定, %~JS~navi~URLを取扱うか ) ◎ If child is a shadow host, then run the inner sanitize steps given child's shadow root, configuration, and handleJavascriptNavigationUrls.
      6. %局所的な属性~群を伴う要素 ~LET «[ ]» ◎ Let elementWithLocalAttributes be «[ ]».
      7. ~IF[ %環境設定[ "`elements$mb" ] ~NEQ ε ]~AND[ %要素~名 ~IN`名前$sub %環境設定[ "`elements$mb" ] ] ⇒ %局所的な属性~群を伴う要素 ~SET `~listから同等な名前を見出す$( %環境設定[ "`elements$mb" ], %要素~名 ) ◎ If configuration["elements"] exists and configuration["elements"] contains elementName, then set elementWithLocalAttributes to configuration["elements"][elementName].
      8. %子 の`属性~list$elを成す ~EACH( %属性 ) に対し: ◎ For each attribute in child's attribute list:

        1. %属性~名 ~LET 新たな `SanitizerAttributeNamespace$I — その ⇒# `name$mbA ~SET %属性 の`局所~名$attr, `namespace$mbA ~SET %属性 の`名前空間$attr ◎ Let attrName be a SanitizerAttributeNamespace with attribute's local name and namespace.
        2. ~IF[ ~OR↓ ]… ◎ ↓

          • %属性~名 ~IN`名前$sub %局所的な属性~群を伴う要素[ "`removeAttributes$mbE" ] ~DF « » ◎ If elementWithLocalAttributes["removeAttributes"] exists and elementWithLocalAttributes["removeAttributes"] contains attrName, then remove attribute.
          • ~AND↓:

            • %属性~名 ~NIN`名前$sub %環境設定[ "`attributes$mb" ] ~DF « %属性~名 »
            • %属性~名 ~NIN`名前$sub %局所的な属性~群を伴う要素[ "`attributes$mbE" ] ~DF « »
            • ~OR↓:

              • `data-^l は %属性 の`局所~名$attrの`符号単位~接頭辞$でない
              • %属性 の`名前空間$attr ~NEQ ~NULL
              • %環境設定[ "`dataAttributes$mb" ] ~NEQ ~T
            ◎ Otherwise, if configuration["attributes"] exists: • If configuration["attributes"] does not contain attrName and elementWithLocalAttributes["attributes"] with default « » does not contain attrName, and if "data-" is not a code unit prefix of attribute's local name or attribute's namespace is not null or configuration["dataAttributes"] is not true, then remove attribute.
          • %属性~名 ~NIN`名前$sub %局所的な属性~群を伴う要素[ "`attributes$mbE" ] ~DF « %属性~名 » ◎ Otherwise: • If elementWithLocalAttributes["attributes"] exists and elementWithLocalAttributes["attributes"] does not contain attrName, then remove attribute.
          • %属性~名 ~IN`名前$sub %環境設定[ "`removeAttributes$mb" ] ~DF « » ◎ • Otherwise, if configuration["removeAttributes"] contains attrName, then remove attribute.

          …ならば ⇒ `属性を除去する$( %属性 ) ◎ ↑

        3. ~ELIF[ %~JS~navi~URLを取扱うか ~EQ ~T ]~AND[ ~OR↓ ]… ◎ If handleJavascriptNavigationUrls is true:

          • ~AND↓:

            • `~javascript_~URLを包含するか否か$( %属性 ) ~EQ ~T
            • ~OR:

              • `組込みの~navigateされる~URLをとる属性~list$を成す ある~item【!entry】として次を満たすものが在る ⇒ [ ~itemを成す要素 ~EQ`名前$sub %要素~名 ]~AND[ ~itemを成す属性 ~EQ`名前$sub %属性~名 ]
              • ~AND↓:

                • %子 の`名前空間$el ~EQ `~MathML名前空間$
                • %属性 の`局所~名$attr ~EQ `href^l
                • %属性 の`名前空間$attr ~IN { ~NULL, `~XLink名前空間$ }
            ◎ If the pair (elementName, attrName) matches an entry in the built-in navigating URL attributes list, and if attribute contains a javascript: URL, then remove attribute. ◎ If child's namespace is the MathML Namespace, attribute's local name is "href", attribute's namespace is null or the XLink namespace, and attribute contains a javascript: URL, then remove attribute.
          • ~AND↓:

            • %属性 の`値$attr ~IN { `href^l, `xlink:href^l }
            • `組込みの~animateされる~URLをとる属性~list$を成す ある~item【!entry】として次を満たすものが在る ⇒ [ ~itemを成す要素 ~EQ`名前$sub %要素~名 ]~AND[ ~itemを成す属性 ~EQ`名前$sub %属性~名 ]
            ◎ If the built-in animating URL attributes list contains the pair (elementName, attrName), and attribute's value is "href" or "xlink:href", then remove attribute.

          …ならば ⇒ `属性を除去する$( %属性 ) ◎ ↑

      9. `内縁な無毒化する手続き$( %子, %環境設定, %~JS~navi~URLを取扱うか ) ◎ Run the inner sanitize steps given child, configuration, and handleJavascriptNavigationUrls.

`~javascript_~URLを包含するか否か@ を決定する~algoは、 所与の ( 属性~node %属性 ) に対し: ◎ To determine whether an attribute attribute contains a javascript: URL:

  1. %~URL ~LET `基本~URL構文解析器$( %属性 の`値$attr ) ◎ Let url be the result of running the basic URL parser on attribute's value.
  2. ~RET ~IS[ %~URL ~NEQ `失敗^i ]~AND[ %~URL の`~scheme$url ~EQ `javascript^l ] ◎ If url is failure, then return false. ◎ Return true if url's scheme is "javascript", and false otherwise.

`要素を除去するよう環境設定する@ ~algoは、 所与の ( `SanitizerConfig$I %環境設定, %要素 ) に対し: ◎ To remove an element element from a SanitizerConfig configuration:

  1. ~Assert: %環境設定 は`妥当$である。 ◎ Assert: configuration is valid.
  2. %要素 ~SET `無毒化器~用の要素を正準-化する$( %要素 ) ◎ Set element to the result of canonicalizing element.
  3. %改変されたか ~LET %環境設定[ "`replaceWithChildrenElements$mb" ] から %要素 と`同等な名前$を`除去する$ ◎ Let modified be the result of removing element from configuration["replaceWithChildrenElements"].
  4. ~IF[ %環境設定[ "`elements$mb" ] ~NEQ ε ]: ◎ If configuration["elements"] exists:

    1. ~IF[ %要素 ~IN`名前$sub %環境設定[ "`elements$mb" ] ]: ◎ If configuration["elements"] contains element:

      1. %環境設定[ "`elements$mb" ] から %要素 と`同等な名前$を`除去する$ ◎ Remove element from configuration["elements"].
      2. ~RET ~T ◎ Return true.
    2. ~RET %改変されたか ◎ Return modified.
  5. ~ELSE: ◎ Otherwise:

    1. ~IF[ %要素 ~IN`名前$sub %環境設定[ "`removeElements$mb" ] ] ⇒ ~RET %改変されたか ◎ If configuration["removeElements"] contains element, then return modified.
    2. %環境設定[ "`removeElements$mb" ] に %要素 を`付加する$【!`付加する$set】 ◎ Append element to configuration["removeElements"].
    3. ~RET ~T ◎ Return true.

`属性を除去するよう環境設定する@ ~algoは、 所与の ( `SanitizerConfig$I %環境設定, %属性 ) に対し: ◎ To remove an attribute attribute from a SanitizerConfig configuration:

  1. ~Assert: %環境設定 は`妥当$である。 ◎ Assert: configuration is valid.
  2. %属性 ~SET `無毒化器~用の名前を正準-化する$( %属性 ) ◎ Set attribute to the result of canonicalizing attribute.
  3. ~IF[ %環境設定[ "`attributes$mb" ] ~NEQ ε ]: ◎ If configuration["attributes"] exists:

    1. %改変されたか ~LET %環境設定[ "`attributes$mb" ] から %属性 と`同等な名前$を`除去する$ ◎ Let modified be the result of removing attribute from configuration["attributes"].
    2. ~IF[ %環境設定[ "`elements$mb" ] ~NEQ ε ]: ◎ If configuration["elements"] exists:

      1. %環境設定[ "`elements$mb" ] を成す ~EACH( %要素 ) に対し: ◎ For each element of configuration["elements"]:

        1. ~IF[ %属性 ~IN`名前$sub %要素[ "`attributes$mbE" ] ~DF « » ]: ◎ If element["attributes"] with default « » contains attribute:

          1. %改変されたか ~SET ~T ◎ Set modified to true.
          2. %要素[ "`attributes$mbE" ] から %属性 と`同等な名前$を`除去する$ ◎ Remove attribute from element["attributes"].
        2. ~IF[ %属性 ~IN`名前$sub %要素[ "`removeAttributes$mbE" ] ~DF « » ]: ◎ If element["removeAttributes"] with default « » contains attribute:

          1. ~Assert: %改変されたか ~EQ ~T ◎ Assert: modified is true.
          2. %要素[ "`removeAttributes$mbE" ] から %属性 と`同等な名前$を`除去する$ ◎ Remove attribute from element["removeAttributes"].
    3. ~RET %改変されたか ◎ Return modified.
  4. ~ELSE: ◎ Otherwise:

    1. ~IF[ %属性 ~IN`名前$sub %環境設定[ "`removeAttributes$mb" ] ] ⇒ ~RET ~F ◎ If configuration["removeAttributes"] contains attribute, then return false.
    2. ~IF[ %環境設定[ "`elements$mb" ] ~NEQ ε ]: ◎ If configuration["elements"] exists:

      1. %環境設定[ "`elements$mb" ] を成す ~EACH( %要素 ) に対し: ◎ For each element in configuration["elements"]:

        1. ~IF[ %属性 ~IN`名前$sub %要素[ "`attributes$mbE" ] ~DF « » ] ⇒ %要素[ "`attributes$mbE" ] から %属性 と`同等な名前$を`除去する$ ◎ If element["attributes"] with default « » contains attribute, then remove attribute from element["attributes"].
        2. ~IF[ %属性 ~IN`名前$sub %要素[ "`removeAttributes$mbE" ] ~DF « » ] ⇒ %要素[ "`removeAttributes$mbE" ] から %属性 と`同等な名前$を`除去する$ ◎ If element["removeAttributes"] with default « » contains attribute, then remove attribute from element["removeAttributes"].
    3. %環境設定[ "`removeAttributes$mb" ] に %属性 を`付加する$【!`付加する$set】 ◎ Append attribute to configuration["removeAttributes"].
    4. ~RET ~T ◎ Return true.

`安全でないものを除去するよう環境設定する@ ~algoは、 所与の ( `SanitizerConfig$I %環境設定 ) に対し: ◎ To remove unsafe from a SanitizerConfig configuration:

  1. ~Assert: %環境設定 は`妥当$である。 ◎ Assert: configuration is valid.
  2. %結果 ~LET ~F ◎ Let result be false.
  3. `組込みの安全な最小限な環境設定$[ "`removeElements$mb" ] を成す ~EACH( %要素 ) に対し: ◎ For each element in built-in safe baseline configuration["removeElements"]:

    1. %改変されたか ~LET `要素を除去するよう環境設定する$( %環境設定, %要素 ) ◎ If removing element from configuration\
    2. ~IF[ %改変されたか ~EQ ~T ] ⇒ %結果 ~SET ~T ◎ is true, then set result to true.
  4. `組込みの安全な最小限な環境設定$[ "`removeAttributes$mb" ] を成す ~EACH( %属性 ) に対し: ◎ For each attribute in built-in safe baseline configuration["removeAttributes"]:

    1. %改変されたか ~LET `属性を除去するよう環境設定する$( %環境設定, %属性 ) ◎ If removing attribute from configuration\
    2. ~IF[ %改変されたか ~EQ ~T ] ⇒ %結果 ~SET ~T ◎ is true, then set result to true.
  5. 【この標準にて定義される】 ~EACH( `~event~handler内容~属性$の名前 %名前 ) に対し: ◎ For each attribute that is an event handler content attribute:

    1. %属性~名 ~LET «[ `name^l → %名前, `namespace^l → ~NULL ]» ◎ ↓
    2. %改変されたか ~LET `属性を除去するよう環境設定する$( %環境設定, %属性~名 ) ◎ If removing attribute from configuration\
    3. ~IF[ %改変されたか ~EQ ~T ] ⇒ %結果 ~SET ~T ◎ is true, then set result to true.
  6. ~RET %結果 ◎ Return result.

`無毒化器~itemを比較する@ ~algoは、 所与の ( `正準的な名前$ %~item~A, `正準的な名前$ %~item~B ) に対し: ◎ To compare sanitizer items itemA and itemB:

  1. %名前空間~A ~LET %~item~A[ "`namespace$mbE" ] ◎ Let namespaceA be itemA["namespace"].
  2. %名前空間~B ~LET %~item~B[ "`namespace$mbE" ] ◎ Let namespaceB be itemB["namespace"].
  3. ~IF[ %名前空間~A ~NEQ %名前空間~B ]:

    1. ~IF[ %名前空間~A ~EQ ~NULL ] ⇒ ~RET ~T
    2. ~IF[ %名前空間~B ~EQ ~NULL ] ⇒ ~RET ~F
    3. ~RET ~IS[ %名前空間~A は %名前空間~B `未満の符号単位~列$である ]
    ◎ If namespaceA is null: • If namespaceB is not null, then return true. ◎ Otherwise: • If namespaceB is null, then return false. • If namespaceA is code unit less than namespaceB, then return true. • If namespaceA is not namespaceB, then return false.
  4. ~RET ~IS[ %~item~A[ "`name$mbE" ] は %~item~B[ "`name$mbE" ] `未満の符号単位~列$である ] ◎ If itemA["name"] is code unit less than itemB["name"], then return true. ◎ Return false.

`属性~群を伴う無毒化器~要素を正準-化する@ ~algoは、 所与の ( `SanitizerElementWithAttributes$I %要素 ) に対し: ◎ To canonicalize a SanitizerElementWithAttributes element:

  1. %結果 ~LET `無毒化器~用の要素を正準-化する$( %要素 ) ◎ Let result be the result of canonicalizing element.
  2. ~IF[ %要素 は辞書である ]: ◎ If element is a dictionary:

    1. ~IF[ %要素[ "`attributes$mbE" ] ~NEQ ε ] ⇒ %結果[ "`attributes$mbE" ] ~SET `無毒化器~用の~listを正準-化する$( %要素[ "`attributes$mbE" ] ) ◎ If element["attributes"] exists, then set result["attributes"] to the result of canonicalizing element["attributes"].
    2. ~IF[ %要素[ "`removeAttributes$mbE" ] ~NEQ ε ] ⇒ %結果[ "`removeAttributes$mbE" ] ~SET `無毒化器~用の~listを正準-化する$( %要素[ "`removeAttributes$mbE" ] ) ◎ If element["removeAttributes"] exists, then set result["removeAttributes"] to the result of canonicalizing element["removeAttributes"].
  3. ~IF[ %結果[ "`attributes$mbE" ] ~EQ ε ]~AND[ %結果[ "`removeAttributes$mbE" ] ~EQ ε ] ⇒ %結果[ "`removeAttributes$mbE" ] ~SET « » ◎ If neither result["attributes"] nor result["removeAttributes"] exists, then set result["removeAttributes"] to an empty list.
  4. ~RET %結果 ◎ Return result.

所与の ( 正準的な `SanitizerConfig$I %環境設定 ) が `妥当@ であるか否かを決定する~algoは: ◎ To determine whether a canonical SanitizerConfig config is valid:

注記: %環境設定 は`環境設定を正準-化する$手続きを経たものであることが期待される。 以下では、 単純に,その~algoにより満たされることが保証される条件を表明することにする。 ◎ It's expected that the configuration being passed in has previously been run through the canonicalize the configuration steps. We will simply assert conditions that that algorithm is guaranteed to hold.

  1. ~Assert: [ %環境設定[ "`elements$mb" ] ~NEQ ε ]~OR[ %環境設定[ "`removeElements$mb" ] ~NEQ ε ] ◎ Assert: config["elements"] exists or config["removeElements"] exists.
  2. ~IF[ %環境設定[ "`elements$mb" ] ~NEQ ε ]~AND[ %環境設定[ "`removeElements$mb" ] ~NEQ ε ] ⇒ ~RET ~F ◎ If config["elements"] exists and config["removeElements"] exists, then return false.
  3. ~Assert: [ %環境設定[ "`processingInstructions$mb" ] ~NEQ ε ]~OR[ %環境設定[ "`removeProcessingInstructions$mb" ] ~NEQ ε ] ◎ Assert: Either config["processingInstructions"] exists or config["removeProcessingInstructions"] exists.
  4. ~IF[ %環境設定[ "`processingInstructions$mb" ] ~NEQ ε ]~AND[ %環境設定[ "`removeProcessingInstructions$mb" ] ~NEQ ε ] ⇒ ~RET ~F ◎ If config["processingInstructions"] exists and config["removeProcessingInstructions"] exists, then return false.
  5. ~Assert: [ %環境設定[ "`attributes$mb" ] ~NEQ ε ]~OR[ %環境設定[ "`removeAttributes$mb" ] ~NEQ ε ] ◎ Assert: Either config["attributes"] exists or config["removeAttributes"] exists.
  6. ~IF[ %環境設定[ "`attributes$mb" ] ~NEQ ε ]~AND[ %環境設定[ "`removeAttributes$mb" ] ~NEQ ε ] ⇒ ~RET ~F ◎ If config["attributes"] exists and config["removeAttributes"] exists, then return false.
  7. ~Assert: %環境設定 内のすべての[ `SanitizerElementNamespaceWithAttributes$I, `SanitizerElementNamespace$I, `SanitizerProcessingInstruction$I, `SanitizerAttributeNamespace$I ]~itemは、 正準的 — すなわち、 `無毒化器~用の名前を正準-化する$~algoを適用済み — である。 ◎ Assert: All SanitizerElementNamespaceWithAttributes, SanitizerElementNamespace, SanitizerProcessingInstruction, and SanitizerAttributeNamespace items in config are canonical, meaning they have been run through canonicalizing, as appropriate.
  8. ~IF[ ~OR↓ ]… ◎ ↓

    • %環境設定[ "`elements$mb" ] ~DF « » には`重複が有る$`名前$sub ◎ If config["elements"] exists: • If config["elements"] has duplicates, then return false.
    • %環境設定[ "`removeElements$mb" ] ~DF « » には`重複が有る$`名前$sub ◎ Otherwise: • If config["removeElements"] has duplicates, then return false.
    • %環境設定[ "`replaceWithChildrenElements$mb" ] ~DF « » には`重複が有る$`名前$sub ◎ If config["replaceWithChildrenElements"] exists and has duplicates, then return false.
    • %環境設定[ "`processingInstructions$mb" ] ~DF « » には`重複が有る$`~target$sub ◎ If config["processingInstructions"] exists: • If config["processingInstructions"] has duplicates, then return false.
    • %環境設定[ "`removeProcessingInstructions$mb" ] ~DF « » には`重複が有る$`~target$sub ◎ Otherwise: • If config["removeProcessingInstructions"] has duplicates, then return false.
    • %環境設定[ "`attributes$mb" ] ~DF « » には`重複が有る$`名前$sub ◎ If config["attributes"] exists: • If config["attributes"] has duplicates, then return false.
    • %環境設定[ "`removeAttributes$mb" ] ~DF « » には`重複が有る$`名前$sub ◎ Otherwise: • If config["removeAttributes"] has duplicates, then return false.

    …ならば ⇒ ~RET ~F ◎ ↑

  9. %置換される要素~群 ~LET %環境設定[ "`replaceWithChildrenElements$mb" ] ◎ ↓
  10. ~IF[ %置換される要素~群 ~NEQ ε ]: ◎ If config["replaceWithChildrenElements"] exists:

    1. %置換される要素~群 を成す ~EACH( %要素 ) に対し ⇒ ~IF[ %要素 ~IN`名前$sub `組込みの置換-可能でない要素~list$ ] ⇒ ~RET ~F ◎ For each element of config["replaceWithChildrenElements"]: • If the built-in non-replaceable elements list contains element, then return false.
    2. ~IF[ ~OR↓ ]…

      • `正準-化された交差集合$( %環境設定[ "`elements$mb" ] ~DF « », %置換される要素~群 ) は`空$でない
      • `正準-化された交差集合$( %環境設定[ "`removeElements$mb" ] ~DF « », %置換される要素~群 ) は`空$でない

      …ならば ⇒ ~RET ~F

      ◎ If config["elements"] exists: • If the intersection of config["elements"] and config["replaceWithChildrenElements"] is not empty, then return false. ◎ Otherwise: • If the intersection of config["removeElements"] and config["replaceWithChildrenElements"] is not empty, then return false.
  11. ~IF[ %環境設定[ "`attributes$mb" ] ~NEQ ε ]: ◎ If config["attributes"] exists:

    1. ~Assert: %環境設定[ "`dataAttributes$mb" ] ~NEQ ε ◎ Assert: config["dataAttributes"] exists.
    2. %環境設定[ "`elements$mb" ] ~DF « » を成す ~EACH( %要素 ) に対し: ◎ If config["elements"] exists: • For each element of config["elements"]:

      1. ~IF[ ~OR↓ ]… ◎ ↓

        • %要素[ "`attributes$mbE" ] ~DF « » には`重複が有る$`名前$sub ◎ If element["attributes"] exists and element["attributes"] has duplicates, then return false.
        • %要素[ "`removeAttributes$mbE" ] ~DF « » には`重複が有る$`名前$sub ◎ If element["removeAttributes"] exists and element["removeAttributes"] has duplicates, then return false.
        • `正準-化された交差集合$( %環境設定[ "`attributes$mb" ], %要素[ "`attributes$mbE" ] ~DF « » ) は`空$でない ◎ If the intersection of config["attributes"] and element["attributes"] with default « » is not empty, then return false.
        • %要素[ "`removeAttributes$mbE" ] ~DF « » は %環境設定[ "`attributes$mb" ] の`下位集合$`名前$subでない ◎ If element["removeAttributes"] with default « » is not a subset of config["attributes"], then return false.

        …ならば ⇒ ~RET ~F ◎ ↑

      2. ~IF[ %環境設定[ "`dataAttributes$mb" ] ~EQ ~T ] ⇒ %要素[ "`attributes$mb" ] を成す ~EACH( %属性 ) に対し ⇒ ~IF[ %属性 は`~custom~data属性$である ] ⇒ ~RET ~F ◎ If config["dataAttributes"] is true and element["attributes"] contains a custom data attribute, then return false.
    3. ~IF[ %環境設定[ "`dataAttributes$mb" ] ~EQ ~T ] ⇒ %環境設定[ "`attributes$mb" ] を成す ~EACH( %属性 ) に対し ⇒ ~IF[ %属性 は`~custom~data属性$である ] ⇒ ~RET ~F ◎ If config["dataAttributes"] is true and config["attributes"] contains a custom data attribute, then return false.
  12. ~ELSE: ◎ Otherwise:

    1. %環境設定[ "`elements$mb" ] ~DF « » を成す ~EACH( %要素 ) に対し: ◎ If config["elements"] exists: • For each element of config["elements"]:

      1. ~IF[ ~OR↓ ]… ◎ ↓

        • [ %要素[ "`attributes$mbE" ] ~NEQ ε ]~AND[ %要素[ "`removeAttributes$mbE" ] ~NEQ ε ] ◎ If element["attributes"] exists and element["removeAttributes"] exists, then return false.
        • %要素[ "`attributes$mbE" ] ~DF « » には`重複が有る$`名前$sub ◎ If element["attributes"] exists and element["attributes"] has duplicates, then return false.
        • %要素[ "`removeAttributes$mbE" ] ~DF « » には`重複が有る$`名前$sub ] ◎ If element["removeAttributes"] exists and element["removeAttributes"] has duplicates, then return false.
        • `正準-化された交差集合$( %環境設定[ "`removeAttributes$mb" ], %要素[ "`attributes$mbE" ] ~DF « » ) は`空$でない ] ◎ If the intersection of config["removeAttributes"] and element["attributes"] with default « » is not empty, then return false.
        • `正準-化された交差集合$( %環境設定[ "`removeAttributes$mb" ], %要素[ "`removeAttributes$mbE" ] ~DF « » ) は`空$でない ◎ If the intersection of config["removeAttributes"] and element["removeAttributes"] with default « » is not empty, then return false.

        …ならば ⇒ ~RET ~F ◎ ↑

    2. ~IF[ %環境設定[ "`dataAttributes$mb" ] ~NEQ ε ] ⇒ ~RET ~F ◎ If config["dataAttributes"] exists, then return false.
  13. ~RET ~T ◎ Return true.

8.6.5. 無毒化~定数

要素の `無毒化~分類@ は、 次に挙げるいずれかをとり得る: ◎ An element's sanitization category can be one of the following:

`既定@san ◎ Default
当の要素は、 既定の `SanitizerConfig$I 内に含まれる。 ◎ The element is included in the default SanitizerConfig.
`安全でない@san ◎ Unsafe
当の要素は、 ~XSSに至らせ得る。 ◎ The element can result in XSS.\
([ `setHTMLUnsafe()$m, `parseHTMLUnsafe()$m ]は,そのような要素を保全する一方で、[ `setHTML()$m, `parseHTML()$m, `removeUnsafe()$m ]は,そのような要素を除去する)。 ◎ (Such elements are preserved by setHTMLUnsafe() or parseHTMLUnsafe(), and removed by setHTML(), parseHTML(), and removeUnsafe().)
`未分類@san ◎ Uncategorized
当の要素は、 除去されることも, 既定で含まれることもないが, 依然として `SanitizerConfig$I に追加され得る。 ◎ The element is neither removed nor included by default, but can still be added to a SanitizerConfig.

`組込みの安全な最小限な環境設定@ は、 各~memberが以下のとおり初期化される `SanitizerConfig$I である: ◎ The built-in safe baseline configuration is a SanitizerConfig.\

`removeElements$mb ◎ Its removeElements list\

次に挙げるものからなる:

  • 個々の~HTML要素のうち,各自の定義の中で`安全でない$sanものとして規範的に~markされたもの
  • 廃用な `frame$e 要素
  • 次に挙げる~SVG要素 ⇒# `script@~SVGinteract#elementdef-script$e, `use@~SVGstruct#elementdef-use$e
◎ consists of all HTML elements normatively marked as Unsafe within their individual definitions, along with the obsolete frame element, and the SVG script and SVG use elements,\ \
`removeAttributes$mb ◎ and its removeAttributes list\
空な~listになる。 ◎ is empty.
注記: ~event~handler内容~属性たちは, 安全な無毒化の間に`安全でないものを除去するよう環境設定する$~algoにより 自動的に除去されるので、 実質的な最小限な環境設定は,それらが `removeAttributes$mb ~list内に含まれたかのように挙動する。 ◎ Event handler content attributes are automatically removed by the remove unsafe algorithm during safe sanitization, so the effective baseline behaves as if they were included in the removeAttributes list.

【 他の~memberは、 利用されない。 】

`組込みの安全な既定の環境設定@ は、 各~memberが以下のとおり初期化される `SanitizerConfig$I である: ◎ The built-in safe default configuration is a SanitizerConfig whose members are initialized as follows:

`processingInstructions$mb
« »
`attributes$mb

次に挙げるものからなる`~list$: ◎ A list consisting of:

【 順序は有意でない ( `get()$m ~methodの注記を見よ)。 これらのうち,多くは、 ~SVG用の`呈示~属性@~SVGstyling#TermPresentationAttribute$であり, `対応する~CSS~prop@~SVGattindex#PresentationAttributes$の定義を参照する。 】

  • `dir@~HTMLdom#attr-dir$a
  • `lang@~HTMLdom#attr-lang$a
  • `title@~HTMLdom#attr-title$a
  • `alignment-baseline@~CSSINLINE#propdef-alignment-baseline$a
  • `baseline-shift@~CSSINLINE#propdef-baseline-shift$a
  • `clip-path@~MASKING1#propdef-clip-path$a
  • `clip-rule@~MASKING1#propdef-clip-rule$a
  • `color@~CSSCOLOR#propdef-color$a
  • `color-interpolation@~SVGpainting#ColorInterpolationProperty$a
  • `cursor@~CSSUI#propdef-cursor$a
  • `direction@~CSSWM#propdef-direction$a
  • `display@~CSSDISP#propdef-display$a
  • `displaystyle@~MATHMLcore#dfn-displaystyle$a
  • `dominant-baseline@~CSSINLINE#propdef-dominant-baseline$a
  • `fill@~SVGpainting#FillProperty$a
  • `fill-opacity@~SVGpainting#FillOpacityProperty$a
  • `fill-rule@~SVGpainting#FillRuleProperty$a
  • `font-family@~CSSFONT#propdef-font-family$a
  • `font-size@~CSSFONT#propdef-font-size$a
  • `font-size-adjust@~CSSFONT#propdef-font-size-adjust$a
  • `font-stretch@~CSSFONT#propdef-font-stretch$a
  • `font-style@~CSSFONT#propdef-font-style$a
  • `font-variant@~CSSFONT#propdef-font-variant$a
  • `font-weight@~CSSFONT#propdef-font-weight$a
  • `letter-spacing@~CSSTEXT#propdef-letter-spacing$a
  • `marker-end@~SVGpainting#MarkerEndProperty$a
  • `marker-mid@~SVGpainting#MarkerMidProperty$a
  • `marker-start@~SVGpainting#MarkerStartProperty$a
  • `mathbackground@~MATHMLcore#dfn-mathbackground$a
  • `mathcolor@~MATHMLcore#dfn-mathcolor$a
  • `mathsize@~MATHMLcore#dfn-mathsize$a
  • `opacity@~CSSCOLOR#propdef-opacity$a
  • `paint-order@~SVGpainting#PaintOrderProperty$a
  • `pointer-events@~SVGinteract#PointerEventsProperty$a
  • `scriptlevel@~MATHMLcore#dfn-scriptlevel$a
  • `shape-rendering@~SVGpainting#ShapeRenderingProperty$a
  • `stop-color@~SVGpservers#StopColorProperty$a
  • `stop-opacity@~SVGpservers#StopOpacityProperty$a
  • `stroke@~SVGpainting#StrokeProperty$a
  • `stroke-dasharray@~SVGpainting#StrokeDasharrayProperty$a
  • `stroke-dashoffset@~SVGpainting#StrokeDashoffsetProperty$a
  • `stroke-linecap@~SVGpainting#StrokeLinecapProperty$a
  • `stroke-linejoin@~SVGpainting#StrokeLinejoinProperty$a
  • `stroke-miterlimit@~SVGpainting#StrokeMiterlimitProperty$a
  • `stroke-opacity@~SVGpainting#StrokeOpacityProperty$a
  • `stroke-width@~SVGpainting#StrokeWidthProperty$a
  • `text-anchor@~SVGtext#TextAnchorProperty$a
  • `text-decoration@~CSSTEXTDECOR#propdef-text-decoration$a
  • `text-overflow@~CSSUI#propdef-text-overflow$a
  • `text-rendering@~SVGpainting#TextRendering$a
  • `transform@~TRANSFORM#propdef-transform$a
  • `transform-origin@~TRANSFORM#propdef-transform-origin$a
  • `unicode-bidi@~CSSWM#propdef-unicode-bidi$a
  • `vector-effect@~SVGcoords#VectorEffectProperty$a
  • `visibility@~CSSDISP#propdef-visibility$a
  • `white-space@~CSSTEXT#propdef-white-space$a
  • `word-spacing@~CSSTEXT#propdef-word-spacing$a
  • `writing-mode@~CSSWM#propdef-writing-mode$a
`comments$mb
~F
`dataAttributes$mb
~F
`elements$mb
個々の~HTML要素のうち[ 各自の定義の中で,規範的に `既定$sanとして分類されたもの ]および[ ~MathML要素/~SVG要素 ]のうち下の表t内に~listされたもの。 それらの定義~内に含められた属性は、 当の要素~用の `attributes$mbE ~list内に含まれる。 ◎ All HTML elements normatively categorized as Default within their individual definitions, alongside the MathML and SVG elements listed in the table below. Attributes included in those definitions are included in each element's respective attributes list.

次の表tに,[ ~MathML要素/~SVG要素 ]のうち[ `組込みの安全な既定の環境設定$において `既定$san に分類されるもの ]を挙げる。 各~要素は、 `SanitizerElementNamespaceWithAttributes$I 辞書として表現される。 この表tを成す各~行における[ “要素” 列は `name$mbE ~member, “名前空間” 列は `namespace$mbE ~member, “許容される属性” 列は `attributes$mbE ~member ]に対応する。 (挙げられた各~属性は、 `SanitizerAttribute$I として 表現される): ◎ The following table lists the MathML and SVG elements that are categorized as Default in the built-in safe default configuration, represented as a list of SanitizerElementNamespaceWithAttributes dictionaries. For each row in the table, the "Element" column corresponds to the name member, the "Namespace" column corresponds to the namespace member, and the "Allowed attributes" column corresponds to the attributes member (where each listed attribute is represented as a SanitizerAttribute in the sequence):

この節における各~表tを成す名前空間~列に挙げられる[ ~MathML/~SVG/~HTML/~XLink ]は、[ `~MathML名前空間$/`~SVG名前空間$/`~HTML名前空間$/`~XLink名前空間$ ]表すとする。 ◎ ↓

要素 名前空間 許容される属性
`math@~MATHMLcore#the-top-level-math-element$e ~MathML
`merror@~MATHMLcore#error-message-merror$e ~MathML
`mfrac@~MATHMLcore#dfn-mfrac$e ~MathML
`mi@~MATHMLcore#the-mi-element$e ~MathML
`mmultiscripts@~MATHMLcore#dfn-mmultiscripts$e ~MathML
`mn@~MATHMLcore#number-mn$e ~MathML
`mo@~MATHMLcore#operator-fence-separator-or-accent-mo$e ~MathML `fence@~MATHMLcore#dfn-fence$a, `form@~MATHMLcore#dfn-form$a, `largeop@~MATHMLcore#dfn-largeop$a, `lspace@~MATHMLcore#dfn-lspace$a, `maxsize@~MATHMLcore#dfn-maxsize$a, `minsize@~MATHMLcore#dfn-minsize$a, `movablelimits@~MATHMLcore#dfn-movablelimits$a, `rspace@~MATHMLcore#dfn-rspace$a, `separator@~MATHMLcore#dfn-separator$a, `stretchy@~MATHMLcore#dfn-stretchy$a, `symmetric@~MATHMLcore#dfn-symmetric$a
`mover@~MATHMLcore#dfn-mover$e ~MathML `accent@~MATHMLcore#dfn-accent$a
`mpadded@~MATHMLcore#dfn-mpadded$e ~MathML `depth@~MATHMLcore#dfn-depth$a, `height@~MATHMLcore#dfn-height$a, `lspace@~MATHMLcore#dfn-lspace$a, `voffset@~MATHMLcore#dfn-voffset$a, `width@~MATHMLcore#dfn-width$a
`mphantom@~MATHMLcore#dfn-mphantom$e ~MathML
`mprescripts@~MATHMLcore#dfn-mprescripts$e ~MathML
`mroot@~MATHMLcore#dfn-mroot$e ~MathML
`mrow@~MATHMLcore#dfn-mrow$e ~MathML
`ms@~MATHMLcore#string-literal-ms$e ~MathML
`mspace@~MATHMLcore#dfn-mspace$e ~MathML `depth@~MATHMLcore#dfn-depth$a, `height@~MATHMLcore#dfn-height$a, `width@~MATHMLcore#dfn-width$a
`msqrt@~MATHMLcore#dfn-msqrt$e ~MathML
`mstyle@~MATHMLcore#dfn-mstyle$e ~MathML
`msub@~MATHMLcore#dfn-msub$e ~MathML
`msubsup@~MATHMLcore#dfn-msubsup$e ~MathML
`msup@~MATHMLcore#dfn-msup$e ~MathML
`mtable@~MATHMLcore#dfn-mtable$e ~MathML
`mtd@~MATHMLcore#dfn-mtd$e ~MathML `columnspan@~MATHMLcore#dfn-columnspan$a, `rowspan@~MATHMLcore#dfn-rowspan$a
`mtext@~MATHMLcore#text-mtext$e ~MathML
`mtr@~MATHMLcore#dfn-mtr$e ~MathML
`munder@~MATHMLcore#dfn-munder$e ~MathML `accentunder@~MATHMLcore#dfn-accentunder$a
`munderover@~MATHMLcore#dfn-munderover$e ~MathML `accent@~MATHMLcore#dfn-accent$a, `accentunder@~MATHMLcore#dfn-accentunder$a
`semantics@~MATHMLcore#dfn-semantics$e ~MathML
`a@~SVGlinking#elementdef-a$e ~SVG `href@~SVGlinking#AElementHrefAttribute$a, `hreflang@~SVGlinking#AElementHreflangAttribute$a, `type@~SVGlinking#AElementTypeAttribute$a
`circle@~SVGshapes#elementdef-circle$e ~SVG `cx@~SVGgeometry#CxProperty$a, `cy@~SVGgeometry#CyProperty$a, `pathLength@~SVGpaths#PathLengthAttribute$a, `r@~SVGgeometry#RProperty$a
`defs@~SVGstruct#elementdef-defs$e ~SVG
`desc@~SVGstruct#elementdef-desc$e ~SVG
`ellipse@~SVGshapes#elementdef-ellipse$e ~SVG `cx@~SVGgeometry#CxProperty$a, `cy@~SVGgeometry#CyProperty$a, `pathLength@~SVGpaths#PathLengthAttribute$a, `rx@~SVGgeometry#RxProperty$a, `ry@~SVGgeometry#RyProperty$a
`foreignObject@~SVGembedded#elementdef-foreignObject$e ~SVG `height@~SVGgeometry#Sizing$a【!#HeightProperty】, `width@~SVGgeometry#Sizing$a【!#WidthProperty】, `x@~SVGgeometry#XProperty$a, `y@~SVGgeometry#YProperty$a
`g@~SVGstruct#elementdef-g$e ~SVG
`line@~SVGshapes#elementdef-line$e ~SVG `pathLength@~SVGpaths#PathLengthAttribute$a, `x1@~SVGshapes#LineElementX1Attribute$a, `x2@~SVGshapes#LineElementX2Attribute$a, `y1@~SVGshapes#LineElementY1Attribute$a, `y2@~SVGshapes#LineElementY2Attribute$a
`marker@~SVGpainting#elementdef-marker$e ~SVG `markerHeight@~SVGpainting#MarkerHeightAttribute$a, `markerUnits@~SVGpainting#MarkerUnitsAttribute$a, `markerWidth@~SVGpainting#MarkerWidthAttribute$a, `orient@~SVGpainting#OrientAttribute$a, `preserveAspectRatio@~SVGcoords#PreserveAspectRatioAttribute$a, `refX@~SVGpainting#MarkerElementRefXAttribute$a, `refY@~SVGpainting#MarkerElementRefYAttribute$a, `viewBox@~SVGcoords#ViewBoxAttribute$a
`metadata@~SVGstruct#elementdef-metadata$e ~SVG
`path@~SVGpaths#elementdef-path$e ~SVG `d@~SVGpaths#DProperty$a, `pathLength@~SVGpaths#PathLengthAttribute$a
`polygon@~SVGshapes#elementdef-polygon$e ~SVG `pathLength@~SVGpaths#PathLengthAttribute$a, `points@~SVGshapes#PolygonElementPointsAttribute$a【!#PointsAttribute】
`polyline@~SVGshapes#elementdef-polyline$e ~SVG `pathLength@~SVGpaths#PathLengthAttribute$a, `points@~SVGshapes#PolylineElementPointsAttribute$a【!#PointsAttribute】
`rect@~SVGshapes#elementdef-rect$e ~SVG `height@~SVGgeometry#Sizing$a【!#HeightProperty】, `pathLength@~SVGpaths#PathLengthAttribute$a, `rx@~SVGgeometry#RxProperty$a, `ry@~SVGgeometry#RyProperty$a, `width@~SVGgeometry#Sizing$a【!#WidthProperty】, `x@~SVGgeometry#XProperty$a, `y@~SVGgeometry#YProperty$a
`svg@~SVGstruct#elementdef-svg$e ~SVG `height@~SVGgeometry#Sizing$a【!#HeightProperty】, `preserveAspectRatio@~SVGcoords#PreserveAspectRatioAttribute$a, `viewBox@~SVGcoords#ViewBoxAttribute$a, `width@~SVGgeometry#Sizing$a【!#WidthProperty】, `x@~SVGgeometry#XProperty$a, `y@~SVGgeometry#YProperty$a
`text@~SVGtext#elementdef-text$e ~SVG `dx@~SVGtext#TextElementDXAttribute$a, `dy@~SVGtext#TextElementDYAttribute$a, `lengthAdjust@~SVGtext#TextElementLengthAdjustAttribute$a, `rotate@~SVGtext#TextElementRotateAttribute$a, `textLength@~SVGtext#TextElementTextLengthAttribute$a, `x@~SVGtext#TextElementXAttribute$a【!~SVGgeometry#XProperty】, `y@~SVGtext#TextElementYAttribute$a【!~SVGgeometry#YProperty】
`textPath@~SVGtext#elementdef-textPath$e ~SVG `lengthAdjust@~SVGtext#TextElementLengthAdjustAttribute$a, `method@~SVGtext#TextPathElementMethodAttribute$a, `path@~SVGtext#TextPathElementPathAttribute$a, `side@~SVGtext#TextPathElementSideAttribute$a, `spacing@~SVGtext#TextPathElementSpacingAttribute$a, `startOffset@~SVGtext#TextPathElementStartOffsetAttribute$a, `textLength@~SVGtext#TextElementTextLengthAttribute$a
`title@~SVGstruct#elementdef-title$e ~SVG
`tspan@~SVGtext#elementdef-tspan$e ~SVG `dx@~SVGtext#TextElementDXAttribute$a, `dy@~SVGtext#TextElementDYAttribute$a, `lengthAdjust@~SVGtext#TextElementLengthAdjustAttribute$a, `rotate@~SVGtext#TextElementRotateAttribute$a, `textLength@~SVGtext#TextElementTextLengthAttribute$a, `x@~SVGtext#TextElementXAttribute$a【!~SVGgeometry#XProperty】, `y@~SVGtext#TextElementYAttribute$a【!~SVGgeometry#YProperty】

`組込みの~navigateされる~URLをとる属性~list@ は、 次に挙げるものからなる: ◎ The built-in navigating URL attributes list corresponds to\

  • 各~HTML要素の規範的な定義において, `~navigateされる~URLをとる属性@ として~markされたもの ◎ all HTML elements marked with navigating URL attributes in their normative definitions,\
  • 次の表tにより表現される, ( 要素, 属性 ) が成す~pairたち ◎ as well as the element-attribute pairs represented in the following table.\

この表tを成す各~行における: ◎ For each row in the table,\

  • 要素は、 `SanitizerElementNamespace$I のうち,その[ `name$mbE / `namespace$mbE ]~memberは[ “要素” / “名前空間” ]列により与えられるものに対応する。 ◎ the element corresponds to a SanitizerElementNamespace whose name member is given by the "Element" column and whose namespace member is given by the "Element namespace" column;\
  • 属性は、 `SanitizerAttributeNamespace$I のうち,その[ `name$mbA / `namespace$mbA ]~memberは[ “属性” / “属性の名前空間” ]列により与えられるものに対応する。 ◎ and the attribute corresponds to a SanitizerAttributeNamespace whose name member is given by the "Attribute" column and whose namespace member is given by the "Attribute namespace" column:
要素 名前空間 属性 属性の名前空間
`a@~SVGlinking#elementdef-a$e ~SVG `href@~SVGlinking#AElementHrefAttribute$a なし
`a@~SVGlinking#elementdef-a$e ~SVG `href@~SVGlinking#AElementHrefAttribute$a ~XLink
◎ Element|Element namespace|Attribute|Attribute namespace a|SVG|href|no namespace a|SVG|href|XLink

`組込みの~animateされる~URLをとる属性~list@ は、 次の表tにより表現される, ( 要素, 属性 ) が成す~pairたちが成す~listである。 この表tを成す各~行における: ◎ The built-in animating URL attributes list is the list of element-attribute pairs represented by the following table. For each row in the table,\

  • 要素は、 `SanitizerElementNamespace$I のうち,その[ `name$mbE / `namespace$mbE ]~memberは[ “要素” / “名前空間” ]列により与えられるものに対応する。 ◎ the element corresponds to a SanitizerElementNamespace whose name member is given by the "Element" column and whose namespace member is given by the "Element namespace" column;\
  • 属性は、 `SanitizerAttributeNamespace$I のうち,その[ `name$mbA ~memberは “属性” 列により与えられ, `namespace$mbA ~memberは ~NULL をとる ]ものに対応する。 ◎ and the attribute corresponds to a SanitizerAttributeNamespace whose name member is given by the "Attribute" column and whose namespace member is null:
要素 名前空間 属性
`animate@~SVGanimate#elementdef-animate$e ~SVG `attributeName@~SVGanimate#AttributeNameAttribute$a
`animateTransform@~SVGanimate#elementdef-animateTransform$e ~SVG `attributeName@~SVGanimate#AttributeNameAttribute$a
`set@~SVGanimate#elementdef-set$e ~SVG `attributeName@~SVGanimate#AttributeNameAttribute$a
◎ Element|Element namespace|Attribute animate|SVG|attributeName animateTransform|SVG|attributeName set|SVG|attributeName

`組込みの置換-可能でない要素~list@ は、 要素のうち,自身の子~群で置換されてはならないものたちを包含する — 置換されると,[ 構文解析し直される課題/妥当でない~node~tree ]へ至らせ得るので。 それは、 下の表tにより表現される `SanitizerElementNamespace$I 辞書たちが成す~listである。 この表tを成す各~行における[ “要素” / “名前空間” ]列は[ `name$mbE / `namespace$mbE ]~memberに対応する: ◎ The built-in non-replaceable elements list contains elements that must not be replaced with their children, as doing so can lead to re-parsing issues or an invalid node tree. It is the following list of SanitizerElementNamespace dictionaries, represented by the table below. For each row in the table, the "Element" column corresponds to the name member, and the "Element namespace" column corresponds to the namespace member:

要素 名前空間
`html^e ~HTML
`svg^e ~SVG
`math^e ~MathML
◎ Element|Element namespace html|HTML svg|SVG math|MathML

8.6.6. ~securityの考慮点

◎非規範的

無毒化器~API( `Sanitizer API^en, 以下,略して “この~API” )には、 ~DOMに基づく~XSSを防止することが意図される — 給された~HTML内容を辿って,環境設定に則って[ 要素/属性 ]を除去することにより。 [ `setHTML()$m, `parseHTML()$m ]~methodは、 その設計により,給された環境設定に関わらず~script能力がある~markupを除去する — 環境設定が,これらの~methodを通して そのような~markupを保全することもできた場合、 それは,~bugである。 ◎ The Sanitizer API is intended to prevent DOM-based cross-site scripting by traversing supplied HTML content and removing elements and attributes according to a configuration. By design, the setHTML() and parseHTML() methods remove script-capable markup regardless of the configuration supplied; if any configuration could preserve such markup through these methods, that would be a bug.

しかしながら、 この~APIが防止できない~securityの課題もある — 以下の各~下位節では、 それらについて述べる。 ◎ However, there are security issues that the Sanitizer API cannot prevent. The following sections describe them.

8.6.6.1. ~server側に反映され, 格納される~XSS
◎非規範的

この~APIは、 もっぱら~DOM内で演算する — それは、 既存の`文書片$を辿って~filterするための能力を追加する。 この~APIは、[ ~server側に反映され, 格納される~XSS ]には取組まない。 ◎ The Sanitizer API operates solely in the DOM and adds a capability to traverse and filter an existing DocumentFragment. The Sanitizer API does not address server-side reflected or stored XSS.

8.6.6.2. ~DOM~clobbering
◎非規範的

~DOM~clobbering【 “痛めつけ” 】は、 悪意的な~HTMLが[ 要素の `id$a 属性や `name^a 属性【たぶん `slot$e 要素の `name$a 】を利用して, ~DOM~prop — ~HTML要素の `children$m ~propなど — が悪意的な内容により隠蔽される ]ようにすることにより,~appを惑わす攻撃である。 ◎ DOM clobbering describes an attack in which malicious HTML confuses an application by using id or name attributes such that DOM properties, such as the children property of an HTML element, are shadowed by malicious content.

この~APIは、 既定では[ ~DOM~clobbering攻撃に抗して保護する ]ことはないが,[ `id$a 属性や `name^a 属性 ]を除去するよう環境設定することはできる。 ◎ The Sanitizer API does not protect against DOM clobbering attacks by default, but can be configured to remove id and name attributes.

8.6.6.3. ~script~gadgetを伴う~XSS
◎非規範的

~script~gadgetは、 既存の[ 普及している~JS~libraryからの~app~code ]を利用して,攻撃者が自前の~codeを実行させる技法である。 これは、[ ある~frameworkに限り,構文解析され解釈される ]ような[ 見かけは潔白な~code/不活~そうに見える~DOM~node ]を注入することにより行われることが多く、 その入力に基づいて~JSの実行を遂行する。 ◎ Script gadgets are a technique in which an attacker uses existing application code from popular JavaScript libraries to cause their own code to execute. This is often done by injecting innocent-looking code or seemingly inert DOM nodes that are only parsed and interpreted by a framework which then performs the execution of JavaScript based on that input.

この~APIは、 これらの攻撃を防止できない。 代わりに、 作者が次を明示的に許容することに依拠する: ◎ The Sanitizer API cannot prevent these attacks. Instead, it relies on authors to explicitly allow\

  • 一般に,未知な要素 ◎ unknown elements in general,\
  • ~template法や~frameworkに特有な~codeに共通的に利用される[ 属性/要素/~markup ] — 次に挙げるものなど ⇒# `data-*$a 属性, `slot$a 属性, `name$a 属性, `slot$e 要素, `template$e 要素 ◎ and additionally to explicitly allow attributes, elements, and markup commonly used for templating and framework-specific code, such as data-* and slot attributes and elements like slot and template.\

これらの制約は、 網羅的ではない — 作者には、[ 自身が利用している第三者-主体~libraryを,この挙動に関して精査すること ]が奨励される。 ◎ These restrictions are not exhaustive and authors are encouraged to examine their third party libraries for this behavior.

8.6.6.4. 変異~XSS
◎非規範的

変異~XSS ( `mutation XSS^en, 略称 mXSS )は、[ 構文解析された~DOM構造が,それを直列化して再び構文解析した結果と同じにならない事例 ]を悪用する攻撃である — 直列化より前に起きた無毒化を素通りするために。 そのような攻撃を遂げる例には、[ 外来な内容や誤って入子にされた~tagに対し,構文解析の挙動が変化すること ]に依拠するものがある。 ◎ Mutation XSS or mXSS describes an attack that exploits cases where the parsed DOM structure is not the same after serializing and parsing again, to bypass sanitization that happens before serialization. An example for carrying out such an attack is by relying on the change of parsing behavior for foreign content or mis-nested tags.

この~APIは、 文字列を~node~treeへ転化する機能~しか提供しない。 この~APIを成す すべての無毒化~method【!無毒化器~関数】は、 文脈を暗黙的に給する — `setHTML()$m は、 現在の要素を利用する/ `Document$I の `parseHTML()$m は、 新たな文書を作成する。 したがって、 この~APIは,変異~XSSにより直に影響されることは無い。 ◎ The Sanitizer API offers only functions that turn a string into a node tree. The context is supplied implicitly by all sanitizer functions: setHTML() uses the current element; Document.parseHTML() creates a new document. Therefore Sanitizer API is not directly affected by mutation XSS.

開発者が無毒化された~node~treeを — 例えば `innerHTML$m を介して — 文字列として検索取得してから,その結果を再び構文解析した場合、 変異~XSSが生じ得る — なので、 そのような実施は,強く忌避される。 それでも,~HTMLを文字列として[ 処理する/渡す ]ことが必要yな場合、 ~DOMの中へ挿入するときには, 信用-済みでないものと見なされ, 無毒化し直される。 言い換えれば、 無毒化されてから直列化された~HTML~treeは, もはや無毒化-済みとは見なされない。 変異~XSSに対するより完全な扱いは、 `MXSS$r にて見出せる。 ◎ If a developer were to retrieve a sanitized node tree as a string, e.g. via innerHTML, and to then parse it again then mutation XSS can occur. This practice is strongly discouraged. If processing or passing of HTML as a string is necessary after all, then any string is to be considered untrusted and re-sanitized when inserted into the DOM. In other words, a sanitized and then serialized HTML tree can no longer be considered sanitized. A more complete treatment of mXSS can be found in [MXSS].