0
I持ってこの正規表現/ javascriptのコード:
toReturn = toReturn.replace(/(\[url=)(.+)(\])(.+)(\[\/url\])/g, '<a target=\"_blank\" href="\$2">\$4</a>');
しかし、問題である、ユーザ入力の場合:
[url=example]example[/url]
some_other_text
[url=example2]example2[/url]
それがします最初の[url =]を最後の[/ url]にリンクしてください。間違ったURLを1つだけ作成する!!!!!
どうすればこの問題を解決できますか?
ユーザーが '[url = javascript:location = http://evil.org] [/ url]'または '[url =">
And how would I stop that Mike Samuel? –
by white-listing URLs by protocol, and properly encoding both the HTML attribute value and the HTML text node using entity escapes. –