Fix calls to trim null

Bug: T348936
Change-Id: I6e3fca041fb81975b175977b9a18d69fbf58620b
This commit is contained in:
Stegmujo 2023-11-03 14:25:21 +00:00
parent f031bd07c5
commit ac1d7a9a7b
No known key found for this signature in database
GPG key ID: BB616B7CC84186BE
3 changed files with 12 additions and 0 deletions

View file

@ -197,7 +197,11 @@ class BaseMethods {
public function checkAndParseDelimiter( $input, $node, $passedArgs,
$operatorContent, $noargs = false, $texClass = "" ) {
if ( $input === null ) {
return null;
}
$resDelimiter = BaseMappings::getDelimiterByKey( trim( $input ) );
if ( $resDelimiter == null ) {
$input = MMLutil::inputPreparation( $input );
$resDelimiter = AMSMappings::getSymbolDelimiterByKey( $input );

View file

@ -157,6 +157,9 @@ class MMLutil {
* @return string prepared input string
*/
public static function inputPreparation( $input ): string {
if ( $input === null ) {
return "";
}
$input = trim( $input );
if ( str_starts_with( $input, "\\" ) && strlen( $input ) >= 2 ) {
$input = substr( $input, 1 );

View file

@ -15,6 +15,11 @@ use MediaWikiUnitTestCase;
* @covers \MediaWiki\Extension\Math\TexVC\TexVC
*/
class MMLRenderTest extends MediaWikiUnitTestCase {
public function testTrimNull() {
$input = "\\bigl( \\begin{smallmatrix}a&b\\\\ c&d\\end{smallmatrix} \\bigr)";
$mathMLtexVC = $this->generateMML( $input );
$this->assertStringContainsString( "mtable", $mathMLtexVC );
}
public function testApplyOperator1() {
$input = "\sup x";