From: Platonides Date: Tue, 11 Jan 2011 18:38:32 +0000 (+0000) Subject: Forbid '<', '>', ' ', '\n', '\r' in parser hook names. X-Git-Tag: 1.31.0-rc.0~32618 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=f1bcac7be1872cb98237d791807c42e25e52bedb;p=lhc%2Fweb%2Fwiklou.git Forbid '<', '>', ' ', '\n', '\r' in parser hook names. Registering a tag hook with < or > on its name resulted in a UNIQ marker. Spaces, tabs or LF do work (CR fails due to the CR->LF transformation), but it's easier to also forbid them, just as they are not allowed in other markup languages. --- diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 9346ddf532..3d37703499 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -4315,6 +4315,7 @@ class Parser { */ public function setHook( $tag, $callback ) { $tag = strtolower( $tag ); + if ( preg_match( '/[<> \r\n]/', $tag, $m ) ) throw new MWException( "Invalid character {$m[0]} in setHook('$tag', ...) call" ); $oldVal = isset( $this->mTagHooks[$tag] ) ? $this->mTagHooks[$tag] : null; $this->mTagHooks[$tag] = $callback; if ( !in_array( $tag, $this->mStripList ) ) { @@ -4326,6 +4327,7 @@ class Parser { function setTransparentTagHook( $tag, $callback ) { $tag = strtolower( $tag ); + if ( preg_match( '/[<> \r\n]/', $tag, $m ) ) throw new MWException( "Invalid character {$m[0]} in setHook('$tag', ...) call" ); $oldVal = isset( $this->mTransparentTagHooks[$tag] ) ? $this->mTransparentTagHooks[$tag] : null; $this->mTransparentTagHooks[$tag] = $callback; @@ -4430,6 +4432,7 @@ class Parser { */ function setFunctionTagHook( $tag, $callback, $flags ) { $tag = strtolower( $tag ); + if ( preg_match( '/[<> \r\n]/', $tag, $m ) ) throw new MWException( "Invalid character {$m[0]} in setHook('$tag', ...) call" ); $old = isset( $this->mFunctionTagHooks[$tag] ) ? $this->mFunctionTagHooks[$tag] : null; $this->mFunctionTagHooks[$tag] = array( $callback, $flags );