阅读本文XSS cheat sheet ,我注意到一个我从未见过的特殊用法:
<img src="/" =_=" title="onerror='prompt(1)'">
“=_=”是什么意思?它在“鼠标悬停”这句话的下方。
最佳答案
它只是元素上的一个属性。它本身没有任何意义,所以它可能只是作为一条红鲱鱼出现。
美化,代码是:
<img
src="/"
=_=" title="
onerror='prompt(1)'"
>
在 HTML 中,=
在属性中指定属性名称和属性值之间的分隔符,所以它是:=_=" title="
^^ attribute name
=_=" title="
^ delimiter between attribute name and attribute value
=_=" title="
^ attribute value contents delimiter
=_=" title="
^^^^^^^ attribute value
=_=" title="
^ attribute value contents delimiter
如果需要,您可以检索属性值。const img = document.querySelector('img');
console.log(img.getAttribute('=_'));
<img
src="/"
=_=" title="
onerror='prompt(1)'"
>
注意属性名是
=_
,而不是 =_=
- 决赛 =
是分隔符,而不是属性名称的一部分。“XSS”仅由
src
引起和 onerror
,而不是其他任何东西。无论您在哪里遇到这种情况,=_
可能根本不做任何事情。它可以,但它可能不会。<img src="/" onerror='prompt(1)'">
关于javascript - =_= 在 JavaScript 或 HTML 中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70457546/