mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-23 23:25:02 +00:00
Handle invalid cache keys on Special:MathShowImage
Special:MathShowImage takes a hash as an HTTP GET parameter. Show an error if the hash does not exist. Bug: T365112 Change-Id: I7d4a6602b8732b0b00cb9cba5800ba2b2fe5044f
This commit is contained in:
parent
17ac038ae4
commit
8aee6acf24
|
@ -121,7 +121,7 @@ class RendererFactory {
|
||||||
return $renderer;
|
return $renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFromHash( $inputHash ) {
|
public function getFromHash( $inputHash ): MathRenderer {
|
||||||
$key = $this->cache->makeGlobalKey(
|
$key = $this->cache->makeGlobalKey(
|
||||||
MathRenderer::class,
|
MathRenderer::class,
|
||||||
$inputHash
|
$inputHash
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace MediaWiki\Extension\Math;
|
namespace MediaWiki\Extension\Math;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
use MediaWiki\Extension\Math\Render\RendererFactory;
|
use MediaWiki\Extension\Math\Render\RendererFactory;
|
||||||
use MediaWiki\SpecialPage\SpecialPage;
|
use MediaWiki\SpecialPage\SpecialPage;
|
||||||
|
|
||||||
|
@ -79,9 +80,17 @@ class SpecialMathShowImage extends SpecialPage {
|
||||||
if ( $hash === '' && $tex === '' && $asciimath === '' ) {
|
if ( $hash === '' && $tex === '' && $asciimath === '' ) {
|
||||||
$this->setHeaders( false );
|
$this->setHeaders( false );
|
||||||
echo $this->printSvgError( 'No Inputhash specified' );
|
echo $this->printSvgError( 'No Inputhash specified' );
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( $tex === '' && $asciimath === '' ) {
|
if ( $tex === '' && $asciimath === '' ) {
|
||||||
|
try {
|
||||||
$this->renderer = $this->rendererFactory->getFromHash( $hash );
|
$this->renderer = $this->rendererFactory->getFromHash( $hash );
|
||||||
|
} catch ( InvalidArgumentException $exception ) {
|
||||||
|
$this->setHeaders( false );
|
||||||
|
echo $this->printSvgError( $exception->getMessage() );
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->noRender = $request->getBool( 'noRender', false );
|
$this->noRender = $request->getBool( 'noRender', false );
|
||||||
$isInDatabase = $this->renderer->readFromCache();
|
$isInDatabase = $this->renderer->readFromCache();
|
||||||
if ( $isInDatabase || $this->noRender ) {
|
if ( $isInDatabase || $this->noRender ) {
|
||||||
|
@ -113,7 +122,6 @@ class SpecialMathShowImage extends SpecialPage {
|
||||||
$this->renderer->writeCache();
|
$this->renderer->writeCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints the specified error message as svg.
|
* Prints the specified error message as svg.
|
||||||
|
|
Loading…
Reference in a new issue