division by zero in remote resizes, restore non-overridable addCode - there is already removeCode for that

This commit is contained in:
real_nowhereman 2009-02-06 20:08:25 +00:00
parent 18ff5adc7d
commit 1f5c7a6bb5
2 changed files with 2 additions and 5 deletions

View File

@ -156,12 +156,9 @@ class StringParser_BBCode extends StringParser {
* @return bool * @return bool
*/ */
function addCode ($name, $callback_type, $callback_func, $callback_params, $content_type, $allowed_within, $not_allowed_within) { function addCode ($name, $callback_type, $callback_func, $callback_params, $content_type, $allowed_within, $not_allowed_within) {
// allow override
/*
if (isset ($this->_codes[$name])) { if (isset ($this->_codes[$name])) {
return false; // already exists return false; // already exists
} }
*/
if (!preg_match ('/^[a-zA-Z0-9*_!+-]+$/', $name, $code)) { if (!preg_match ('/^[a-zA-Z0-9*_!+-]+$/', $name, $code)) {
return false; // invalid return false; // invalid
} }

View File

@ -210,12 +210,12 @@ function do_bbcode_img ($action, $attributes, $content, $params, $node_object) {
$height = (int)$attributes['height']; $height = (int)$attributes['height'];
// if width or height are set we calc proportions // if width or height are set we calc proportions
}elseif (isset($attributes['width'])) { }elseif (isset($attributes['width'])) {
$scalefact = ($attributes['width'] / $orig_w); $scalefact = $orig_w? ($attributes['width'] / $orig_w) : 0;
$width = (int) $attributes['width']; $width = (int) $attributes['width'];
$height = (int) ($scalefact*$orig_h); $height = (int) ($scalefact*$orig_h);
}elseif (isset($attributes['height'])) { }elseif (isset($attributes['height'])) {
$scalefact = ($attributes['height'] / $orig_h); $scalefact = $orig_w? ($attributes['height'] / $orig_h) : 0;
$height = (int) $attributes['height']; $height = (int) $attributes['height'];
$width = (int) ($scalefact*$orig_w); $width = (int) ($scalefact*$orig_w);
} }