mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-15 11:59:56 +00:00
XW-2444: error when color is in wrong format
This commit is contained in:
parent
d56e77855c
commit
194b8e4e03
|
@ -17,6 +17,7 @@ $messages['en'] = array(
|
|||
'portable-infobox-xml-parse-error-tag-name-mismatch' => 'Opening and ending tag mismatch',
|
||||
'portable-infobox-xml-parse-error-tag-not-finished' => 'Premature end of tag',
|
||||
'portable-infobox-xml-parse-error-infobox-tag-attribute-unsupported' => 'Attribute "$1" is not supported in <infobox> tag',
|
||||
'portable-infobox-unsupported-color-format' => 'Unsupported color format. Currently, only hexadecimal values are supported.'
|
||||
);
|
||||
|
||||
$messages['qqq'] = array(
|
||||
|
@ -34,6 +35,7 @@ $messages['qqq'] = array(
|
|||
'portable-infobox-xml-parse-error-tag-name-mismatch' => 'XML Error: Opening and ending tag mismatch (for example: <data></label>)',
|
||||
'portable-infobox-xml-parse-error-tag-not-finished' => 'XML Error: premature end of tag',
|
||||
'portable-infobox-xml-parse-error-infobox-tag-attribute-unsupported' => 'Unsupported attribute used inside <infobox> tag. $1 param contains attribute name.',
|
||||
'portable-infobox-unsupported-color-format' => 'Error message displayed if user typed color in unsupported format'
|
||||
);
|
||||
|
||||
$messages['de'] = array(
|
||||
|
|
|
@ -67,6 +67,9 @@ $wgAutoloadClasses[ 'ApiQueryPortableInfobox' ] = $dir . 'controllers/ApiQueryPo
|
|||
$wgAutoloadClasses[ 'PortableInfoboxHooks' ] = $dir . 'PortableInfoboxHooks.class.php';
|
||||
$wgAutoloadClasses[ 'ApiQueryAllinfoboxes' ] = $dir . 'controllers/ApiQueryAllinfoboxes.class.php';
|
||||
|
||||
$wgAutoloadClasses[ 'InvalidParamValueException' ] = $dir . 'controllers/InvalidParamValueException.php';
|
||||
|
||||
|
||||
// query pages
|
||||
$wgAutoloadClasses[ 'AllinfoboxesQueryPage' ] = $dir . 'querypage/AllinfoboxesQueryPage.php';
|
||||
|
||||
|
|
4
controllers/InvalidParamValueException.php
Normal file
4
controllers/InvalidParamValueException.php
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
|
||||
class InvalidParamValueException extends \Exception {
|
||||
}
|
|
@ -117,6 +117,8 @@ class PortableInfoboxParserTagController extends WikiaController {
|
|||
return $this->handleXmlParseError( $e->getErrors(), $text );
|
||||
} catch ( \Wikia\PortableInfobox\Helpers\InvalidInfoboxParamsException $e ) {
|
||||
return $this->handleError( wfMessage( 'portable-infobox-xml-parse-error-infobox-tag-attribute-unsupported', [ $e->getMessage() ] )->escaped() );
|
||||
} catch ( InvalidParamValueException $e ) {
|
||||
return $this->handleError(wfMessage( "portable-infobox-unsupported-color-format" )->escaped() );
|
||||
}
|
||||
|
||||
$marker = $parser->uniqPrefix() . "-" . self::PARSER_TAG_NAME . "-{$this->markerNumber}" . Parser::MARKER_SUFFIX;
|
||||
|
@ -210,7 +212,11 @@ class PortableInfoboxParserTagController extends WikiaController {
|
|||
$color = isset( $params[ $defaultParam ] ) ? trim($params[ $defaultParam ]) : '';
|
||||
}
|
||||
|
||||
return $this->isValidHexColor( $color ) ? $color : '';
|
||||
if ( !$this->isValidHexColor( $color ) ) {
|
||||
throw new InvalidParamValueException();
|
||||
}
|
||||
|
||||
return $color;
|
||||
}
|
||||
|
||||
private function isValidHexColor( $color ) {
|
||||
|
|
Loading…
Reference in a new issue