Skip to content

Fixed regex for validate action in admin menu #25612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/code/Magento/Backend/Model/Menu/Item/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
namespace Magento\Backend\Model\Menu\Item;

/**
* Class Validator
*
* @package Magento\Backend\Model\Menu\Item
* @api
* @since 100.0.2
*/
Expand Down Expand Up @@ -49,7 +52,7 @@ public function __construct()

$attributeValidator = new \Zend_Validate();
$attributeValidator->addValidator(new \Zend_Validate_StringLength(['min' => 3]));
$attributeValidator->addValidator(new \Zend_Validate_Regex('/^[A-Za-z0-9\/_]+$/'));
$attributeValidator->addValidator(new \Zend_Validate_Regex('/^[A-Za-z0-9\/_\-]+$/'));

$textValidator = new \Zend_Validate_StringLength(['min' => 3, 'max' => 50]);

Expand Down Expand Up @@ -101,6 +104,7 @@ private function checkMenuItemIsRemoved($data)

/**
* Check that menu item contains all required data
*
* @param array $data
*
* @throws \BadMethodCallException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
' resource="Test_Value::value"/></menu></config>',
[
"Element 'add', attribute 'action': [facet 'pattern'] The value '' is not accepted by the " .
"pattern '[a-zA-Z0-9/_]{3,}'.\nLine: 1\n",
"pattern '[a-zA-Z0-9/_\-]{3,}'.\nLine: 1\n",
"Element 'add', attribute 'action': '' is not a valid value of the atomic type 'typeAction'.\nLine: 1\n"
],
],
Expand All @@ -20,7 +20,7 @@
'resource="Test_Value::value"/></menu></config>',
[
"Element 'add', attribute 'action': [facet 'pattern'] The value 'ad' is not accepted by the " .
"pattern '[a-zA-Z0-9/_]{3,}'.\nLine: 1\n",
"pattern '[a-zA-Z0-9/_\-]{3,}'.\nLine: 1\n",
"Element 'add', attribute 'action': 'ad' is not a valid value of the atomic type 'typeAction'.\nLine: 1\n"
],
],
Expand All @@ -31,7 +31,7 @@
'</menu></config>',
[
"Element 'add', attribute 'action': [facet 'pattern'] The value 'adm$#@inhtml/notification' is not " .
"accepted by the pattern '[a-zA-Z0-9/_]{3,}'.\nLine: 1\n",
"accepted by the pattern '[a-zA-Z0-9/_\-]{3,}'.\nLine: 1\n",
"Element 'add', attribute 'action': 'adm$#@inhtml/notification' is not a valid value of the atomic " .
"type 'typeAction'.\nLine: 1\n"
],
Expand Down Expand Up @@ -452,7 +452,7 @@
'<?xml version="1.0"?><config><menu><update action="" ' . 'id="Test_Value::some_value"/></menu></config>',
[
"Element 'update', attribute 'action': [facet 'pattern'] The value '' is not accepted by the " .
"pattern '[a-zA-Z0-9/_]{3,}'.\nLine: 1\n",
"pattern '[a-zA-Z0-9/_\-]{3,}'.\nLine: 1\n",
"Element 'update', attribute 'action': '' is not a valid value of the atomic type 'typeAction'.\nLine: 1\n"
],
],
Expand All @@ -462,7 +462,7 @@
'resource="Test_Value::value"/></menu></config>',
[
"Element 'update', attribute 'action': [facet 'pattern'] The value 'v' is not accepted by the " .
"pattern '[a-zA-Z0-9/_]{3,}'.\nLine: 1\n",
"pattern '[a-zA-Z0-9/_\-]{3,}'.\nLine: 1\n",
"Element 'update', attribute 'action': 'v' is not a valid value of the atomic type 'typeAction'.\nLine: 1\n"
],
],
Expand All @@ -471,7 +471,7 @@
'id="Test_Value::some_value"/></menu></config>',
[
"Element 'update', attribute 'action': [facet 'pattern'] The value '/@##gt;' is not " .
"accepted by the pattern '[a-zA-Z0-9/_]{3,}'.\nLine: 1\n",
"accepted by the pattern '[a-zA-Z0-9/_\-]{3,}'.\nLine: 1\n",
"Element 'update', attribute 'action': '/@##gt;' is not a valid value of the atomic" .
" type 'typeAction'.\nLine: 1\n"
],
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/etc/menu.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="[a-zA-Z0-9/_]{3,}" />
<xs:pattern value="[a-zA-Z0-9/_\-]{3,}" />
</xs:restriction>
</xs:simpleType>

Expand Down