Skip to content

Commit 6083ad3

Browse files
authored
Merge pull request #6149 from BOINC/dpa_bbcode4
web (forums): fix XSS vulnerability
2 parents ca85ef5 + 03914f7 commit 6083ad3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

html/inc/text_transform.inc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ function bb2html_aux($text, $export) {
175175
// [2] => a.b.c
176176
// )
177177

178+
$email_addr_regex = "([A-Za-z0-9\.\-\_\@]*)";
179+
// should match all valid email addrs,
180+
// but not any hacker stuff like " alert(1)
178181
$httpsregex = "(?:\"?)https\:\/\/([^\[\"<\ ]+)(?:\"?)";
179182
// List of allowable tags
180183
$bbtags = array (
@@ -198,8 +201,8 @@ function bb2html_aux($text, $export) {
198201
"@\[color=(?:\"?)(.{3,8})(?:\"?)\](.*?)\[/color\]@is",
199202
"@((?:<ol>|<ul>).*?)\n\*([^\n]+)\n(.*?(</ol>|</ul>))@is",
200203
"@\[size=([1-9]|[0-2][0-9])\](.*?)\[/size\]@is",
201-
"@\[mailto\](.*?)\[/mailto\]@is",
202-
"@\[email\](.*?)\[/email\]@is",
204+
"@\[mailto\]$email_addr_regex\[/mailto\]@is",
205+
"@\[email\]$email_addr_regex\[/email\]@is",
203206
"@\[github\](?:\#|ticket:)(\d+)\[/github\]@is",
204207
"@\[github\]wiki:(.*?)\[/github\]@is",
205208
);

0 commit comments

Comments
 (0)