Merge pull request 'Fix HTML attribute parsing for escaped quotes' (#480) from mkljczk/akkoma-fe:get-attrs-fix into develop
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

Reviewed-on: #480
Reviewed-by: Oneric <oneric@noreply.akkoma>
This commit is contained in:
Oneric 2026-02-19 12:31:59 +00:00
commit a123b41a2f

View file

@ -22,7 +22,7 @@ export const getAttrs = tag => {
.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]