Skip to content

Commit e8ff5cc

Browse files
committed
Update Regex
1 parent 098b765 commit e8ff5cc

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Controller/Adminhtml/Index/Save.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
/**
44
* @Author: nguyen
55
* @Date: 2020-05-31 14:56:43
6-
* @Last Modified by: nguyen
7-
* @Last Modified time: 2020-06-12 13:57:13
6+
* @Last Modified by: Alex Dong
7+
* @Last Modified time: 2020-06-12 16:21:00
88
*/
99

1010
namespace Magepow\Theme\Controller\Adminhtml\Index;
@@ -38,6 +38,8 @@ public function execute()
3838
$parentTheme = $data['parent_theme'];
3939
$themeTitle = $data['theme_title'];
4040
$themePath = isset($data['theme_path']) ? $data['theme_path'] : $model->getThemePath();
41+
$themePath = trim($themePath);
42+
$themePath = str_replace(' ', '_', $themePath);;
4143

4244
if($id && in_array($themePath, $this->defaultTheme)){
4345
$this->messageManager->addError(__('You can\'t edit default theme %1.', $themePath));
@@ -48,7 +50,7 @@ public function execute()
4850
$frontend = 'design' . DIRECTORY_SEPARATOR . 'frontend';
4951
$dir = $this->_filesystem->getDirectoryWrite(DirectoryList::APP);
5052
$theme = $this->_objectManager->create('Magento\Theme\Model\Theme');
51-
if(!preg_match('/[a-zA-Z0-9_]*[a-zA-Z0-9_]\/[a-zA-Z0-9_]*[a-zA-Z0-9_]/', $themePath)){
53+
if(!preg_match('/^[a-zA-Z0-9_]+\/+[a-zA-Z0-9_]+$/', $themePath)){
5254
$this->messageManager->addError(__('Theme Path %1 wrong format', $themePath));
5355
$this->_getSession()->setFormData($data);
5456
return $resultRedirect->setPath('*/*/edit');
@@ -80,7 +82,7 @@ public function execute()
8082
}
8183

8284
$dir->writeFile($filePathXml, 'tmp');
83-
85+
$data['theme_path'] = $themePath;
8486
$data['parent_id'] = $parent->getData('theme_id');
8587
$data['theme_title'] = $parent->getData('theme_title');
8688
$data['preview_image'] = NULL;

0 commit comments

Comments
 (0)