mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-01-18 13:54:01 +08:00
Add regexp rule support for texture name
This commit is contained in:
parent
4fd3a07224
commit
5b1667d798
@ -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();
|
||||
|
@ -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'
|
||||
]);
|
||||
|
@ -32,6 +32,7 @@ return [
|
||||
'update_source' => 'https://work.prinzeugen.net/update.json',
|
||||
'copyright_text' => '<strong>Copyright © '.getdate()['year'].' <a href="{site_url}">{site_name}</a>.</strong> 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',
|
||||
|
@ -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. <code>{tid}</code> will be replaced with texture id, <code>{name}</code> will be replaced with texture name, <code>{url}</code> will be replaced with current URL.
|
||||
|
@ -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.
|
||||
|
@ -103,6 +103,10 @@ general:
|
||||
title: 失效材质
|
||||
label: 自动删除失效材质
|
||||
hint: 自动从皮肤库中删除文件不存在的材质记录
|
||||
texture_name_regexp:
|
||||
title: 材质名称规则
|
||||
hint: 皮肤库上传材质时名称的正则表达式。留空表示允许使用除半角单双引号、反斜杠以外的任意字符。
|
||||
placeholder: 正则表达式,不懂别乱填
|
||||
comment_script:
|
||||
title: 评论代码
|
||||
description: 评论代码内可使用占位符,<code>{tid}</code> 将会被自动替换为材质的 id,<code>{name}</code> 会被替换为材质名称,<code>{url}</code> 会被替换为当前页面地址。
|
||||
|
@ -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: 其他人将不会在皮肤库中看到此材质
|
||||
|
@ -30,7 +30,12 @@
|
||||
<div class="box-body">
|
||||
<div class="form-group">
|
||||
<label for="name">@lang('skinlib.upload.texture-name')</label>
|
||||
<input id="name" class="form-control" type="text" placeholder="@lang('skinlib.upload.name-rule')" />
|
||||
@php
|
||||
$regexp = option('texture_name_regexp');
|
||||
@endphp
|
||||
<input id="name" class="form-control" type="text" placeholder="{{
|
||||
$regexp ? trans('skinlib.upload.name-rule-regexp', compact('regexp')) : trans('skinlib.upload.name-rule')
|
||||
}}" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
@ -429,6 +429,18 @@ class SkinlibControllerTest extends TestCase
|
||||
'msg' => trans('validation.no_special_chars', ['attribute' => 'Name'])
|
||||
]);
|
||||
|
||||
// Specified regular expression for texture name
|
||||
option(['texture_name_regexp' => '/\\d+/']);
|
||||
$this->postJson('/skinlib/upload', [
|
||||
'name' => 'abc'
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest'
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.regex', ['attribute' => 'Name'])
|
||||
]);
|
||||
option(['texture_name_regexp' => null]);
|
||||
|
||||
// Without file
|
||||
$this->postJson('/skinlib/upload', [
|
||||
'name' => 'texture'
|
||||
|
Loading…
Reference in New Issue
Block a user