Fix HTML attribute parsing, discard attributes not strating with a letter

このコミットが含まれているのは:
Alexander Tumin 2023-05-31 00:25:10 +03:00
コミット 9baffbfbde
2個のファイルの変更2行の追加1行の削除

1
changelog.d/html-attribute-parsing.fix ノーマルファイル
ファイルの表示

@ -0,0 +1 @@
Fix HTML attribute parsing, discard attributes not strating with a letter

ファイルの表示

@ -22,7 +22,7 @@ export const getAttrs = (tag, filter) => {
.replace(new RegExp('^' + getTagName(tag)), '')
.replace(/\/?$/, '')
.trim()
const attrs = Array.from(innertag.matchAll(/([a-z0-9-]+)(?:=("[^"]+?"|'[^']+?'))?/gi))
const attrs = Array.from(innertag.matchAll(/([a-z]+[a-z0-9-]*)(?:=("[^"]+?"|'[^']+?'))?/gi))
.map(([trash, key, value]) => [key, value])
.map(([k, v]) => {
if (!v) return [k, true]