Commit aefac90e authored by Medicean's avatar Medicean

(Enhance:ShellManager) 新增「自定义数据分割符」配置

parent df00fef8
......@@ -2,6 +2,17 @@
> 有空会补补BUG、添添新功能。
> 同时也欢迎大家的参与!感谢各位朋友的支持! .TAT.
## `v(2.1.8)`
* 新增「自定义数据分割符」配置
> 你可以将任何你喜欢的字符组合定义成数据的「起始符」或「结束符」
![data_separtor_1.png](https://i.loli.net/2019/11/05/per1BvOMh5IKZqt.png)
![data_separtor_2.png](https://i.loli.net/2019/11/05/QECmJprI5FldB9b.png)
## 2019/10/30 `v(2.1.7)`
### 安全更新
......
{
"name": "antsword",
"version": "2.1.7",
"version": "2.1.7.1",
"description": "中国蚁剑是一款跨平台的开源网站管理工具",
"main": "app.js",
"dependencies": {
......
......@@ -62,14 +62,17 @@ class ASP extends Base {
*/
complete(data, force_default = false) {
// 分隔符号
let tag_s = Math
.random()
.toString(16)
.substr(2, parseInt(Math.random() * 8 + 5)); // '->|';
let tag_e = Math
.random()
.toString(16)
.substr(2, parseInt(Math.random() * 8 + 5)); // '|<-';
let tag_s, tag_e;
if (this.__opts__['otherConf'].hasOwnProperty('use-custom-datatag') && this.__opts__['otherConf']['use-custom-datatag'] == 1 && this.__opts__['otherConf']['custom-datatag-tags']) {
tag_s = this.__opts__['otherConf']['custom-datatag-tags'];
} else {
tag_s = Math.random().toString(16).substr(2, parseInt(Math.random() * 8 + 5)); // "->|";
}
if (this.__opts__['otherConf'].hasOwnProperty('use-custom-datatag') && this.__opts__['otherConf']['use-custom-datatag'] == 1 && this.__opts__['otherConf']['custom-datatag-tage']) {
tag_e = this.__opts__['otherConf']['custom-datatag-tage'];
} else {
tag_e = Math.random().toString(16).substr(2, parseInt(Math.random() * 8 + 5)); // "|<-";
}
// let formatter = new this.format(this.__opts__['encode']);
let formatter = Base
......
......@@ -64,14 +64,17 @@ class ASPX extends Base {
*/
complete(data, force_default = false) {
// 分隔符号
let tag_s = Math
.random()
.toString(16)
.substr(2, parseInt(Math.random() * 8 + 5)); // '->|';
let tag_e = Math
.random()
.toString(16)
.substr(2, parseInt(Math.random() * 8 + 5)); // '|<-';
let tag_s, tag_e;
if (this.__opts__['otherConf'].hasOwnProperty('use-custom-datatag') && this.__opts__['otherConf']['use-custom-datatag'] == 1 && this.__opts__['otherConf']['custom-datatag-tags']) {
tag_s = this.__opts__['otherConf']['custom-datatag-tags'];
} else {
tag_s = Math.random().toString(16).substr(2, parseInt(Math.random() * 8 + 5)); // "->|";
}
if (this.__opts__['otherConf'].hasOwnProperty('use-custom-datatag') && this.__opts__['otherConf']['use-custom-datatag'] == 1 && this.__opts__['otherConf']['custom-datatag-tage']) {
tag_e = this.__opts__['otherConf']['custom-datatag-tage'];
} else {
tag_e = Math.random().toString(16).substr(2, parseInt(Math.random() * 8 + 5)); // "|<-";
}
// let formatter = new this.format(this.__opts__['encode']);
let formatter = Base
......
......@@ -55,9 +55,17 @@ class CUSTOM extends Base {
*/
complete(data, force_default = false) {
// 分隔符号
let tag_s = '->|';
let tag_e = '|<-';
let tag_s, tag_e;
if (this.__opts__['otherConf'].hasOwnProperty('use-custom-datatag') && this.__opts__['otherConf']['use-custom-datatag'] == 1 && this.__opts__['otherConf']['custom-datatag-tags']) {
tag_s = this.__opts__['otherConf']['custom-datatag-tags'];
} else {
tag_s = "->|";
}
if (this.__opts__['otherConf'].hasOwnProperty('use-custom-datatag') && this.__opts__['otherConf']['use-custom-datatag'] == 1 && this.__opts__['otherConf']['custom-datatag-tage']) {
tag_e = this.__opts__['otherConf']['custom-datatag-tage'];
} else {
tag_e = "|<-";
}
// 使用编码器进行处理并返回
return this.encodeComplete(tag_s, tag_e, data);
}
......
......@@ -62,15 +62,18 @@ class PHP extends Base {
*/
complete(data, force_default = false) {
// 分隔符号
let tag_s, tag_e;
if (this.__opts__['otherConf'].hasOwnProperty('use-custom-datatag') && this.__opts__['otherConf']['use-custom-datatag'] == 1 && this.__opts__['otherConf']['custom-datatag-tags']) {
tag_s = this.__opts__['otherConf']['custom-datatag-tags'];
} else {
tag_s = Math.random().toString(16).substr(2, parseInt(Math.random() * 8 + 5)); // "->|";
}
if (this.__opts__['otherConf'].hasOwnProperty('use-custom-datatag') && this.__opts__['otherConf']['use-custom-datatag'] == 1 && this.__opts__['otherConf']['custom-datatag-tage']) {
tag_e = this.__opts__['otherConf']['custom-datatag-tage'];
} else {
tag_e = Math.random().toString(16).substr(2, parseInt(Math.random() * 8 + 5)); // "|<-";
}
let tag_s = Math
.random()
.toString(16)
.substr(2, parseInt(Math.random() * 8 + 5)); // "->|";
let tag_e = Math
.random()
.toString(16)
.substr(2, parseInt(Math.random() * 8 + 5)); // "|<-";
let asencCode;
if (!force_default) {
asencCode = this.__decoder__[this.__opts__['decoder'] || 'default'].asoutput();
......
......@@ -14,15 +14,17 @@ class PHP4 extends PHP {
*/
complete(data, force_default = false) {
// 分隔符号
let tag_s = Math
.random()
.toString(16)
.substr(2, parseInt(Math.random() * 8 + 5)); // "->|";
let tag_e = Math
.random()
.toString(16)
.substr(2, parseInt(Math.random() * 8 + 5)); // "|<-";
let tag_s, tag_e;
if (this.__opts__['otherConf'].hasOwnProperty('use-custom-datatag') && this.__opts__['otherConf']['use-custom-datatag'] == 1 && this.__opts__['otherConf']['custom-datatag-tags']) {
tag_s = this.__opts__['otherConf']['custom-datatag-tags'];
} else {
tag_s = Math.random().toString(16).substr(2, parseInt(Math.random() * 8 + 5)); // "->|";
}
if (this.__opts__['otherConf'].hasOwnProperty('use-custom-datatag') && this.__opts__['otherConf']['use-custom-datatag'] == 1 && this.__opts__['otherConf']['custom-datatag-tage']) {
tag_e = this.__opts__['otherConf']['custom-datatag-tage'];
} else {
tag_e = Math.random().toString(16).substr(2, parseInt(Math.random() * 8 + 5)); // "|<-";
}
let asencCode;
if (!force_default) {
asencCode = this.__decoder__[this.__opts__['decoder'] || 'default'].asoutput();
......
......@@ -191,7 +191,15 @@ module.exports = {
filemanagerCache: "Use the filemanager's cache",
uploadFragment: "Upload File Fragmentation Size",
requestTimeout: 'Request timeout',
commandPath: 'Custom terminal-execPath'
commandPath: 'Custom terminal-execPath',
customDatatag: {
title: 'Data separator',
usecustomdatatag: 'Use custom data separator',
tags: 'Start tag',
tage: 'End tag',
exphint: 'The data separator should be the same as other unrelated characters on the page',
valideq: 'Start tag and End tag cannot be the same'
},
}
},
toolbar: {
......
......@@ -191,7 +191,15 @@ module.exports = {
filemanagerCache: '文件管理使用缓存',
uploadFragment: '上传文件分片大小',
requestTimeout: '请求超时',
commandPath: '自定义终端执行路径'
commandPath: '自定义终端执行路径',
customDatatag: {
title: '数据分割符',
usecustomdatatag: '开启自定义数据分割符',
tags: '开始标记',
tage: '结束标记',
exphint: '数据分割符请避免和页面中其它不相关的字符相同',
valideq: '开始标记与结束标记不能相同'
},
}
},
toolbar: {
......
......@@ -190,7 +190,15 @@ module.exports = {
filemanagerCache: '文件管理使用緩存',
uploadFragment: '上傳文件分片大小',
requestTimeout: '請求超時',
commandPath: '自定義終端執行路徑'
commandPath: '自定義終端執行路徑',
customDatatag: {
title: '數據分割符',
usecustomdatatag: '開啟自定義數據分割符',
tags: '開始標記',
tage: '結束標記',
exphint: '數據分割符請避免和頁面中其它不相關的字符相同',
valideq: '開始標記與結束標記不能相同'
},
}
},
toolbar: {
......
......@@ -190,7 +190,15 @@ module.exports = {
filemanagerCache: '文件管理使用緩存',
uploadFragment: '上傳文件分片大小',
requestTimeout: '請求超時',
commandPath: '自定義終端執行路徑'
commandPath: '自定義終端執行路徑',
customDatatag: {
title: '數據分割符',
usecustomdatatag: '開啟自定義數據分割符',
tags: '開始標記',
tage: '結束標記',
exphint: '數據分割符請避免和頁面中其它不相關的字符相同',
valideq: '開始標記與結束標記不能相同'
},
}
},
toolbar: {
......
......@@ -50,6 +50,11 @@ class Form {
"httpConf": opts.http,
"otherConf": opts.other
}
if (opt['otherConf']['use-custom-datatag'] === 1) {
if (opt['otherConf']['custom-datatag-tags'] === opt['otherConf']['custom-datatag-tage']) {
return toastr.warning(LANG['list']['otherConf']['customDatatag']['valideq'], LANG_T['warning']);
}
}
win.progressOn();
let core = new antSword["core"][opt['type']](opt);
core
......@@ -72,11 +77,27 @@ class Form {
if (!this.baseForm.validate() || !this.httpForm.validate() || !this.otherForm.validate()) {
return toastr.warning(LANG['list']['add']['warning'], LANG_T['warning']);
};
let _opts = this._parseFormData(this.baseForm.getValues(), this.httpForm.getValues(), this.otherForm.getValues());
let _opt = {
"url": _opts.base['url'],
"pwd": _opts.base['pwd'],
"type": _opts.base['type'],
"encode": _opts.base['encode'],
"encoder": _opts.base['encoder'],
"decoder": _opts.base['decoder'],
"httpConf": _opts.http,
"otherConf": _opts.other
}
if (_opt['otherConf']['use-custom-datatag'] === 1) {
if (_opt['otherConf']['custom-datatag-tags'] === _opt['otherConf']['custom-datatag-tage']) {
return toastr.warning(LANG['list']['otherConf']['customDatatag']['valideq'], LANG_T['warning']);
}
}
// 回调数据
if (callback) {
win.progressOn();
setTimeout(() => {
callback(this._parseFormData(this.baseForm.getValues(), this.httpForm.getValues(), this.otherForm.getValues())).then((msg) => {
callback(_opts).then((msg) => {
// 添加/保存完毕后回调
win.close();
toastr.success(msg, LANG_T['success']);
......@@ -453,7 +474,10 @@ class Form {
'filemanager-cache': 1,
'upload-fragment': '500',
'request-timeout': '10000',
'command-path': ''
'command-path': '',
'use-custom-datatag': 0,
'custom-datatag-tags': '',
'custom-datatag-tage': ''
}, arg.otherConf);
const form = this
.accordion
......@@ -471,12 +495,12 @@ class Form {
name: 'ignore-https',
label: LANG['list']['otherConf']['nohttps'],
checked: opt['ignore-https'] === 1
},{
}, {
type: "checkbox",
name: 'use-random-variable',
label: LANG['list']['otherConf']['userandomvariable'],
checked: opt['use-random-variable'] === 1
},{
}, {
type: "checkbox",
name: 'use-multipart',
label: LANG['list']['otherConf']['usemultipart'],
......@@ -653,6 +677,87 @@ class Form {
});
return ret;
})(['/bin/sh', 'cmd'])
}, {
type: 'fieldset',
offsetLeft: 0,
label: LANG['list']['otherConf']['customDatatag']['title'],
list: [{
type: 'block',
offsetLeft: 0,
list: [{
type: "checkbox",
name: 'use-custom-datatag',
label: LANG['list']['otherConf']['customDatatag']['usecustomdatatag'],
checked: opt['use-custom-datatag'] === 1
}]
}, {
type: 'block',
offsetLeft: 0,
list: [{
type: 'label',
label: LANG['list']['otherConf']['customDatatag']['tags']
}, {
type: 'newcolumn'
}, {
type: 'combo',
label: '',
validate: '',
inputWidth: 80,
name: "custom-datatag-tags",
options: ((items) => {
let ret = [];
// 如果自定义的路径不在items里,则++
if (items.indexOf(opt['custom-datatag-tags']) === -1) {
items.unshift(opt['custom-datatag-tags']);
}
items.map((_) => {
ret.push({
text: _,
value: _,
selected: opt['custom-datatag-tags'] === _
})
});
return ret;
})([
'->|',
'~~>|',
'__}|'
])
}, {
type: 'newcolumn'
}, {
type: 'label',
label: LANG['list']['otherConf']['customDatatag']['tage'],
offsetLeft: 30
}, {
type: 'newcolumn'
}, {
type: 'combo',
label: '',
validate: '',
inputWidth: 80,
name: "custom-datatag-tage",
options: ((items) => {
let ret = [];
// 如果自定义的路径不在items里,则++
if (items.indexOf(opt['custom-datatag-tage']) === -1) {
items.unshift(opt['custom-datatag-tage']);
}
items.map((_) => {
ret.push({
text: _,
value: _,
selected: opt['custom-datatag-tage'] === _
})
});
return ret;
})([
'|<-',
'|<~~',
'|{~~'
])
}]
}]
}]
}], true);
form.attachEvent('onChange', (name, value, state) => {
......@@ -673,6 +778,14 @@ class Form {
});
}
break;
case 'use-custom-datatag':
if (state == true && form.isItemChecked('use-custom-datatag')) {
layer.open({
title: LANG_T['info'],
content: LANG['list']['otherConf']['customDatatag']['exphint']
})
}
break;
default:
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment