Serious bug with the discussion boards

- A malformed [Thread][/Thread] tag can lead to an infinite loop on the event / thread view. Fixed.
pull/217/head
iglocska 2014-01-07 16:12:47 +01:00
parent cbcd7ac625
commit 6e842da5bc
1 changed files with 3 additions and 1 deletions

View File

@ -16,14 +16,16 @@ App::uses('AppHelper', 'View/Helper');
}
}
$matches = array();
while (preg_match ('%\[thread\](.*?)\[/thread\]%is', $string, $matches)) {
if (!empty($matches) && is_numeric($matches[1])) {
$string = preg_replace('%\[thread\]' . $matches[1] . '\[/thread\]%i', '<a href=/threads/view/' . $matches[1] . '> Thread ' . $matches[1] . '</a>', $string);
} else {
$string = preg_replace('%\[event\]' . $matches[1] . '\[/event\]%i', '%Malformed_Thread_Link%', $string);
$string = preg_replace('%\[thread\]' . $matches[1] . '\[/thread\]%i', '%Malformed_Thread_Link%', $string);
}
$matches = array();
}
return $string;
}
}