diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php
index 3b41fe92..1efd0993 100644
--- a/app/Http/Controllers/AdminController.php
+++ b/app/Http/Controllers/AdminController.php
@@ -205,6 +205,8 @@ class AdminController extends Controller
$form->checkbox('auto_del_invalid_texture')->label()->hint();
+ $form->text('texture_name_regexp')->hint()->placeholder();
+
$form->textarea('comment_script')->rows(6)->description();
$form->checkbox('allow_sending_statistics')->label()->hint();
diff --git a/app/Http/Controllers/SkinlibController.php b/app/Http/Controllers/SkinlibController.php
index e534ca25..10f186e1 100644
--- a/app/Http/Controllers/SkinlibController.php
+++ b/app/Http/Controllers/SkinlibController.php
@@ -313,7 +313,10 @@ class SkinlibController extends Controller
}
$this->validate($request, [
- 'name' => 'required|no_special_chars',
+ 'name' => [
+ 'required',
+ option('texture_name_regexp') ? 'regex:'.option('texture_name_regexp') : 'no_special_chars'
+ ],
'file' => 'required|max:'.option('max_upload_file_size'),
'public' => 'required'
]);
diff --git a/config/options.php b/config/options.php
index 18b8826f..65793a0b 100644
--- a/config/options.php
+++ b/config/options.php
@@ -32,6 +32,7 @@ return [
'update_source' => 'https://work.prinzeugen.net/update.json',
'copyright_text' => 'Copyright © '.getdate()['year'].' {site_name}. All rights reserved.',
'auto_del_invalid_texture' => 'false',
+ 'texture_name_regexp' => '',
'return_200_when_notfound' => 'false',
'cache_expire_time' => '31536000',
'max_upload_file_size' => '1024',
diff --git a/resources/lang/en/options.yml b/resources/lang/en/options.yml
index 9cd1d8b0..fad5cc9a 100644
--- a/resources/lang/en/options.yml
+++ b/resources/lang/en/options.yml
@@ -103,6 +103,10 @@ general:
title: Invalid Textures
label: Delete invalid textures automatically.
hint: Delete textures records whose file no longer exists from skinlib.
+ texture_name_regexp:
+ title: Texture Name Rules
+ hint: The RegExp for validating name of uploaded textures. Leave empty to allow any character except single, double quote and backslash.
+ placeholder: Regular Expressions
comment_script:
title: Comment Script
description: Placeholders are available in comment scripts. {tid} will be replaced with texture id, {name} will be replaced with texture name, {url} will be replaced with current URL.
diff --git a/resources/lang/en/skinlib.yml b/resources/lang/en/skinlib.yml
index cd907acb..deb945e2 100644
--- a/resources/lang/en/skinlib.yml
+++ b/resources/lang/en/skinlib.yml
@@ -61,6 +61,7 @@ upload:
texture-name: Texture Name
name-rule: Less than 32 characters and must not contain any special one.
+ name-rule-regexp: Custom name rules are applied as :regexp
texture-type: Texture Type
select-file: Select File
private-score-notice: It will spend you more scores to set it as private. You will be charged :score scores for every KB storage.
diff --git a/resources/lang/zh_CN/options.yml b/resources/lang/zh_CN/options.yml
index e236ad73..32e17df3 100644
--- a/resources/lang/zh_CN/options.yml
+++ b/resources/lang/zh_CN/options.yml
@@ -103,6 +103,10 @@ general:
title: 失效材质
label: 自动删除失效材质
hint: 自动从皮肤库中删除文件不存在的材质记录
+ texture_name_regexp:
+ title: 材质名称规则
+ hint: 皮肤库上传材质时名称的正则表达式。留空表示允许使用除半角单双引号、反斜杠以外的任意字符。
+ placeholder: 正则表达式,不懂别乱填
comment_script:
title: 评论代码
description: 评论代码内可使用占位符,{tid} 将会被自动替换为材质的 id,{name} 会被替换为材质名称,{url} 会被替换为当前页面地址。
diff --git a/resources/lang/zh_CN/skinlib.yml b/resources/lang/zh_CN/skinlib.yml
index 9d1ce783..a2fe8919 100644
--- a/resources/lang/zh_CN/skinlib.yml
+++ b/resources/lang/zh_CN/skinlib.yml
@@ -61,6 +61,7 @@ upload:
texture-name: 材质名称
name-rule: 材质名称应该小于 32 个字节且不能包含奇怪的符号
texture-type: 材质类型
+ name-rule-regexp: 本站已应用特殊的名称规则::regexp
select-file: 选择文件
private-score-notice: 私密材质将会消耗更多的积分:每 KB 存储空间 :score 积分
privacy-notice: 其他人将不会在皮肤库中看到此材质
diff --git a/resources/views/skinlib/upload.tpl b/resources/views/skinlib/upload.tpl
index 5adfe668..8ae88d4f 100644
--- a/resources/views/skinlib/upload.tpl
+++ b/resources/views/skinlib/upload.tpl
@@ -30,7 +30,12 @@