mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-22 20:02:15 +09:00
Add list of reserved words #763
This commit is contained in:
parent
fae2a05b6f
commit
97047d1279
6 changed files with 83 additions and 7 deletions
|
|
@ -173,6 +173,11 @@ class Context
|
|||
*/
|
||||
private static $_blacklist = null;
|
||||
|
||||
/**
|
||||
* Reserved words cache
|
||||
*/
|
||||
private static $_reserved = null;
|
||||
|
||||
/**
|
||||
* Singleton instance
|
||||
* @var object
|
||||
|
|
@ -2482,6 +2487,26 @@ class Context
|
|||
return isset(self::$_blacklist[$plugin_name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a word is reserved in Rhymix
|
||||
*
|
||||
* @param string $word
|
||||
* @return bool
|
||||
*/
|
||||
public static function isReservedWord($word)
|
||||
{
|
||||
if (self::$_reserved === null)
|
||||
{
|
||||
self::$_reserved = (include RX_BASEDIR . 'common/defaults/reserved.php');
|
||||
if (!is_array(self::$_reserved))
|
||||
{
|
||||
self::$_reserved = array();
|
||||
}
|
||||
}
|
||||
|
||||
return isset(self::$_reserved[$word]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a local path into an URL
|
||||
*
|
||||
|
|
|
|||
28
common/defaults/reserved.php
Normal file
28
common/defaults/reserved.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Reserved words for Rhymix
|
||||
*
|
||||
* Copyright (c) Rhymix Developers and Contributors
|
||||
*/
|
||||
return array(
|
||||
'mid' => true,
|
||||
'vid' => true,
|
||||
'act' => true,
|
||||
'admin' => true,
|
||||
'module' => true,
|
||||
'module_srl' => true,
|
||||
'member_srl' => true,
|
||||
'menu_srl' => true,
|
||||
'layout_srl' => true,
|
||||
'mlayout_srl' => true,
|
||||
'document_srl' => true,
|
||||
'comment_srl' => true,
|
||||
'file_srl' => true,
|
||||
'regdate' => true,
|
||||
'list_order' => true,
|
||||
'sort_index' => true,
|
||||
'order_type' => true,
|
||||
'search_target' => true,
|
||||
'search_keyword' => true,
|
||||
);
|
||||
|
|
@ -65,7 +65,7 @@ $lang->cmd_find_module = 'Find Module';
|
|||
$lang->cmd_find_langcode = 'Find lang code';
|
||||
$lang->msg_new_module = 'Create new module';
|
||||
$lang->msg_update_module = 'Modify module';
|
||||
$lang->msg_module_name_exists = 'The name already exists. Please try another name.';
|
||||
$lang->msg_module_name_exists = 'The name already exists or is not usable. Please try another name.';
|
||||
$lang->msg_module_not_exists = 'Module matching the name is not found.';
|
||||
$lang->msg_category_is_null = 'There is no registered category.';
|
||||
$lang->msg_grant_is_null = 'There is no permission list.';
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ $lang->cmd_find_module = '모듈 찾기';
|
|||
$lang->cmd_find_langcode = '언어 코드 찾기';
|
||||
$lang->msg_new_module = '모듈 생성';
|
||||
$lang->msg_update_module = '모듈 수정';
|
||||
$lang->msg_module_name_exists = '이미 존재하는 모듈 이름입니다. 다른 이름을 입력해주세요.';
|
||||
$lang->msg_module_name_exists = '이미 존재하거나 사용할 수 없는 모듈 이름입니다. 다른 이름을 입력해 주세요.';
|
||||
$lang->msg_module_not_exists = '해당 모듈이 존재하지 않습니다.';
|
||||
$lang->msg_category_is_null = '등록된 분류가 없습니다.';
|
||||
$lang->msg_grant_is_null = '등록된 권한 대상이 없습니다.';
|
||||
|
|
|
|||
|
|
@ -19,20 +19,31 @@ class moduleModel extends module
|
|||
*/
|
||||
function isIDExists($id, $site_srl = 0)
|
||||
{
|
||||
if(!preg_match('/^[a-z]{1}([a-z0-9_]+)$/i',$id)) return true;
|
||||
// directory and rss/atom/api reserved checking, etc.
|
||||
$dirs = FileHandler::readDir(_XE_PATH_);
|
||||
if (!preg_match('/^[a-z]{1}([a-z0-9_]+)$/i', $id))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (Context::isReservedWord(strtolower($id)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$dirs = array_map('strtolower', FileHandler::readDir(_XE_PATH_));
|
||||
$dirs[] = 'rss';
|
||||
$dirs[] = 'atom';
|
||||
$dirs[] = 'api';
|
||||
$dirs[] = 'admin';
|
||||
if(in_array($id, $dirs)) return true;
|
||||
if (in_array(strtolower($id), $dirs))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// mid test
|
||||
$args = new stdClass();
|
||||
$args->mid = $id;
|
||||
$args->site_srl = $site_srl;
|
||||
$output = executeQuery('module.isExistsModuleName', $args);
|
||||
if($output->data->count) return true;
|
||||
|
||||
// vid test (check mid != vid if site_srl=0, which means it is not a virtual site)
|
||||
if(!$site_srl)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -85,4 +85,16 @@ class ContextTest extends \Codeception\TestCase\Test
|
|||
Context::setResponseMethod('HTML');
|
||||
$this->assertEquals(Context::getResponseMethod(), 'HTML');
|
||||
}
|
||||
|
||||
public function testBlacklistedPlugin()
|
||||
{
|
||||
$this->assertTrue(Context::isBlacklistedPlugin('autolang'));
|
||||
$this->assertFalse(Context::isBlacklistedPlugin('document'));
|
||||
}
|
||||
|
||||
public function testReservedWord()
|
||||
{
|
||||
$this->assertTrue(Context::isReservedWord('mid'));
|
||||
$this->assertFalse(Context::isReservedWord('foo'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue