[ticket/12273] Do not allow 3.1-A1 version

PHPBB3-12273
This commit is contained in:
Joas Schilling 2014-04-25 12:31:57 +02:00
parent b32895308d
commit 48278f122c
3 changed files with 12 additions and 23 deletions

View file

@ -544,23 +544,15 @@ class php_exporter
*/ */
public function validate_since($line) public function validate_since($line)
{ {
$since = substr(ltrim($line, "\t"), strlen('* @since ')); $match = array();
preg_match('#^\* @since (\d+\.\d+\.\d+(?:-(?:a|b|rc|pl)\d+)?)$#', ltrim($line, "\t"), $match);
if ($since !== trim($since)) if (!isset($match[1]))
{ {
throw new \LogicException("Invalid '@since' information for event " throw new \LogicException("Invalid '@since' information for event "
. "'{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'", 1); . "'{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'");
} }
$since = ($since === '3.1-A1') ? '3.1.0-a1' : $since; return $match[1];
if (!preg_match('#^\d+\.\d+\.\d+(?:-(?:a|b|rc|pl)\d+)?$#', $since))
{
throw new \LogicException("Invalid '@since' information for event "
. "'{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'", 2);
}
return $since;
} }
/** /**

View file

@ -33,7 +33,7 @@
* @var array page_data Posting page data that should be passed to the * @var array page_data Posting page data that should be passed to the
* posting page via $template->assign_vars() * posting page via $template->assign_vars()
* @var object message_parser The message parser object * @var object message_parser The message parser object
* @since 3.1-A1 * @since 3.1.0-a1
* @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title, * @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title,
* s_topic_icons, form_enctype, s_action, s_hidden_fields, * s_topic_icons, form_enctype, s_action, s_hidden_fields,
* post_id, topic_id, forum_id, submit, preview, save, load, * post_id, topic_id, forum_id, submit, preview, save, load,

View file

@ -114,7 +114,6 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
array('* @since 3.1.0-a1', '3.1.0-a1'), array('* @since 3.1.0-a1', '3.1.0-a1'),
array('* @since 3.1.0-b3', '3.1.0-b3'), array('* @since 3.1.0-b3', '3.1.0-b3'),
array(' * @since 3.1.0-b3', '3.1.0-b3'), array(' * @since 3.1.0-b3', '3.1.0-b3'),
array('* @since 3.1-A1', '3.1.0-a1'),
); );
} }
@ -129,12 +128,11 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
static public function validate_since_throws_data() static public function validate_since_throws_data()
{ {
return array( return array(
array(' * @since 3.1.0-a1', 1), array(' * @since 3.1.0-a1'),
array('* @since 3.1.0-a1 ', 1), array('* @since 3.1.0-a1 '),
array('* @since 3.1.0-a1 bertie is cool', 2), array('* @since 3.1.0-a1 bertie is cool'),
array('bertie* @since 3.1.0-a1', 2), array('bertie* @since 3.1.0-a1'),
array('* @since 3.1-A2', 2), array('* @since 3.1-A2'),
array('* @since 3.1-B3', 2),
); );
} }
@ -142,9 +140,8 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
* @dataProvider validate_since_throws_data * @dataProvider validate_since_throws_data
* @expectedException LogicException * @expectedException LogicException
*/ */
public function test_validate_since_throws($since, $exception_code) public function test_validate_since_throws($since)
{ {
$this->setExpectedException('LogicException', '', $exception_code);
$this->exporter->validate_since($since); $this->exporter->validate_since($since);
} }