From 11d26bdb944390d8d378172e087c95d26929f9ea Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Wed, 17 May 2023 23:47:45 +0300 Subject: [PATCH] Fixing line error reporting for some edge cases --- parser.inc.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/parser.inc.php b/parser.inc.php index c356acf..307c8cf 100644 --- a/parser.inc.php +++ b/parser.inc.php @@ -594,11 +594,15 @@ class mtgMetaInfoParser private function _validatePropToken($name, $value) { - if(!isset($this->config['valid_tokens']) || !$this->config['valid_tokens']) + if(!isset($this->config['valid_tokens']) || + !is_array($this->config['valid_tokens'])) return; if(!in_array($name, $this->config['valid_tokens'])) + { + --$this->line; //hack for more precise reporting throw new Exception("Unknown token '$name'"); + } } private function _symbol() @@ -779,7 +783,7 @@ class mtgMetaInfoParser $t = ord($t); if($t !== $this->token) { - $this->_error("Expecting '" . $this->_toStr($t) . "' instead got '" . $this->_toStr($this->token) . "'"); + $this->_error("expecting '" . $this->_toStr($t) . "' instead got '" . $this->_toStr($this->token) . "'"); } $attr = $this->attribute; @@ -796,7 +800,7 @@ class mtgMetaInfoParser private function _error($msg) { - throw new Exception($msg . "(token: {$this->token}, attr: {$this->attribute}})"); + throw new Exception($msg . "(token: {$this->token}, attr: {$this->attribute})"); } }