X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FImageFunctions.php;h=af05c1c9f88c0d48b339112b697f35891d86b6ce;hb=85eee307b22944f74b5e1e5476d3274ff6083b8e;hp=75755588acb200b9c368721cf53677e006e71006;hpb=45432053e82145707870ed54405b93cef5832fde;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ImageFunctions.php b/includes/ImageFunctions.php index 75755588ac..af05c1c9f8 100644 --- a/includes/ImageFunctions.php +++ b/includes/ImageFunctions.php @@ -1,113 +1,4 @@ 1.0, // "User units" pixels by default '%' => 2.0, // Fake it! ); + $matches = array(); if( preg_match( '/^(\d+(?:\.\d+)?)(em|ex|px|pt|pc|cm|mm|in|%|)$/', $length, $matches ) ) { $length = floatval( $matches[1] ); $unit = $matches[2]; @@ -156,14 +48,15 @@ function wfGetSVGsize( $filename ) { fclose( $f ); // Uber-crappy hack! Run through a real XML parser. + $matches = array(); if( !preg_match( '/]*)\s*>/s', $chunk, $matches ) ) { return false; } $tag = $matches[1]; - if( preg_match( '/\bwidth\s*=\s*("[^"]+"|\'[^\']+\')/s', $tag, $matches ) ) { + if( preg_match( '/(?:^|\s)width\s*=\s*("[^"]+"|\'[^\']+\')/s', $tag, $matches ) ) { $width = wfScaleSVGUnit( trim( substr( $matches[1], 1, -1 ) ) ); } - if( preg_match( '/\bheight\s*=\s*("[^"]+"|\'[^\']+\')/s', $tag, $matches ) ) { + if( preg_match( '/(?:^|\s)height\s*=\s*("[^"]+"|\'[^\']+\')/s', $tag, $matches ) ) { $height = wfScaleSVGUnit( trim( substr( $matches[1], 1, -1 ) ) ); } @@ -180,8 +73,8 @@ function wfGetSVGsize( $filename ) { * * Any subsequent links on the same line are considered to be exceptions, * i.e. articles where the image may occur inline. * - * @param string $name the image name to check - * @param Title $contextTitle The page on which the image occurs, if known + * @param $name string the image name to check + * @param $contextTitle Title: the page on which the image occurs, if known * @return bool */ function wfIsBadImage( $name, $contextTitle = false ) { @@ -206,6 +99,7 @@ function wfIsBadImage( $name, $contextTitle = false ) { } # Find all links + $m = array(); if ( !preg_match_all( '/\[\[:?(.*?)\]\]/', $line, $m ) ) { continue; } @@ -228,7 +122,7 @@ function wfIsBadImage( $name, $contextTitle = false ) { } } } - + $contextKey = $contextTitle ? $contextTitle->getPrefixedDBkey() : false; $bad = isset( $badImages[$name] ) && !isset( $badImages[$name][$contextKey] ); wfProfileOut( __METHOD__ ); @@ -251,6 +145,3 @@ function wfFitBoxWidth( $boxWidth, $boxHeight, $maxHeight ) { else return $roundedUp; } - - -?>