mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-06 08:05:18 -04:00
webui: allow only whitelisted link protocols to prevent javascript in links
This commit is contained in:
parent
ff9bf71aa8
commit
d94124a18b
3 changed files with 54 additions and 14 deletions
|
@ -333,8 +333,18 @@ void ChatHandler::tick()
|
|||
&& last_six_chars.size() >= a.size()
|
||||
&& last_six_chars.substr(last_six_chars.size()-a.size()) == a)
|
||||
{
|
||||
current_link.third = out.size();
|
||||
links.push_back(current_link);
|
||||
// only allow these protocols
|
||||
// we don't want for example javascript:alert(0)
|
||||
std::string http = "http://";
|
||||
std::string https = "https://";
|
||||
std::string retroshare = "retroshare://";
|
||||
if( out.substr(current_link.first, http.size()) == http
|
||||
|| out.substr(current_link.first, https.size()) == https
|
||||
|| out.substr(current_link.first, retroshare.size()) == retroshare)
|
||||
{
|
||||
current_link.third = out.size();
|
||||
links.push_back(current_link);
|
||||
}
|
||||
current_link = Triple();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue