Commit 03c5cf92 authored by Medicean's avatar Medicean

fix jsp probedb bug

parent 1a30ec6e
...@@ -6,6 +6,7 @@ const LANG = antSword['language']['database']; ...@@ -6,6 +6,7 @@ const LANG = antSword['language']['database'];
const LANG_T = antSword['language']['toastr']; const LANG_T = antSword['language']['toastr'];
const dialog = antSword.remote.dialog; const dialog = antSword.remote.dialog;
const fs = require('fs'); const fs = require('fs');
const Decodes = antSword.Decodes;
class JSP { class JSP {
...@@ -728,12 +729,50 @@ class JSP { ...@@ -728,12 +729,50 @@ class JSP {
}); });
} }
parseResult(data) {
// 1.分割数组
const arr = data.split('\n');
// 2.判断数据
if (arr.length < 2) {
return toastr.error(LANG['result']['error']['parse'], LANG_T['error']);
};
// 3.行头
let header_arr = (arr[0]).replace(/,/g, '&#44;').split('\t|\t');
if (header_arr.length === 1) {
return toastr.warning(LANG['result']['error']['noresult'], LANG_T['warning']);
};
if (header_arr[header_arr.length - 1] === '\r') {
header_arr.pop();
};
arr.shift();
// 4.数据
let data_arr = [];
arr.map((_) => {
let _data = _.split('\t|\t');
for (let i = 0; i < _data.length; i++) {
let buff = Buffer.from(_data[i], "base64");
let encoding = Decodes.detectEncoding(buff, { defaultEncoding: "unknown" });
if (encoding == "unknown") {
encoding = this.dbconf['encode'] || '';
}
encoding = encoding != "" ? encoding : this.opt.core.__opts__['encode'];
let text = Decodes.decode(buff, encoding);
_data[i] = antSword.noxss(text);
}
data_arr.push(_data);
});
data_arr.pop();
return {
headers: header_arr,
datas: data_arr
}
}
// 更新SQL执行结果 // 更新SQL执行结果
updateResult(data) { updateResult(data) {
// 1.分割数组 // 1.分割数组
const arr = data.split('\n'); const arr = data.split('\n');
// let arr = []; _arr.map((_) => { arr.push(antSword.noxss(_)); }); // 2.判断数据
// console.log(_arr, arr); 2.判断数据
if (arr.length < 2) { if (arr.length < 2) {
return toastr.error(LANG['result']['error']['parse'], LANG_T['error']); return toastr.error(LANG['result']['error']['parse'], LANG_T['error']);
}; };
...@@ -750,6 +789,16 @@ class JSP { ...@@ -750,6 +789,16 @@ class JSP {
let data_arr = []; let data_arr = [];
arr.map((_) => { arr.map((_) => {
let _data = _.split('\t|\t'); let _data = _.split('\t|\t');
for (let i = 0; i < _data.length; i++) {
let buff = new Buffer.from(_data[i], "base64");
let encoding = Decodes.detectEncoding(buff, { defaultEncoding: "unknown" });
if (encoding == "unknown") {
encoding = this.dbconf['encode'] || '';
}
encoding = encoding != "" ? encoding : this.opt.core.__opts__['encode'];
let text = Decodes.decode(buff, encoding);
_data[i] = antSword.noxss(text, false);
}
data_arr.push(_data); data_arr.push(_data);
}); });
data_arr.pop(); data_arr.pop();
......
...@@ -100,7 +100,7 @@ class FileManager { ...@@ -100,7 +100,7 @@ class FileManager {
this.isWin = false; this.isWin = false;
} else { } else {
// windows 盘符统一大写 // windows 盘符统一大写
info_path = `${info_path.substr(0,1).toUpperCase()}${info_path.substr(1)}`; info_path = `${info_path.substr(0, 1).toUpperCase()}${info_path.substr(1)}`;
info_drive = info_drive.toUpperCase(); info_drive = info_drive.toUpperCase();
}; };
this.path = info_path; this.path = info_path;
...@@ -145,11 +145,11 @@ class FileManager { ...@@ -145,11 +145,11 @@ class FileManager {
let self = this; let self = this;
if (self.isWin) { // 处理输入为 f:\ 这种情况 if (self.isWin) { // 处理输入为 f:\ 这种情况
p = p.replace(/\\/g, '/'); p = p.replace(/\\/g, '/');
p = p.substr(1, 2) == ":/" ? `${p.substr(0,1).toUpperCase()}${p.substr(1)}` : p; p = p.substr(1, 2) == ":/" ? `${p.substr(0, 1).toUpperCase()}${p.substr(1)}` : p;
} }
let path = this.changePath(p); let path = this.changePath(p);
if (self.isWin) { // 处理输入为 f: 这种情况 if (self.isWin) { // 处理输入为 f: 这种情况
path = path.substr(1, 2) == ":/" ? `${path.substr(0,1).toUpperCase()}${path.substr(1)}` : path; path = path.substr(1, 2) == ":/" ? `${path.substr(0, 1).toUpperCase()}${path.substr(1)}` : path;
} }
let cache; let cache;
...@@ -208,6 +208,8 @@ class FileManager { ...@@ -208,6 +208,8 @@ class FileManager {
this.cache.set(cache_tag, JSON.stringify(data)); this.cache.set(cache_tag, JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
toastr.error((err instanceof Object) ? JSON.stringify(err) : String(err), LANG_T['error']); toastr.error((err instanceof Object) ? JSON.stringify(err) : String(err), LANG_T['error']);
this.folder.cell.progressOff();
this.files.cell.progressOff();
}) })
// this.core.filemanager.dir({ // this.core.filemanager.dir({
...@@ -944,7 +946,7 @@ class FileManager { ...@@ -944,7 +946,7 @@ class FileManager {
icon: 'code', icon: 'code',
type: 'button' type: 'button'
}; };
(_ === ext) ? _opt['selected'] = true: 0; (_ === ext) ? _opt['selected'] = true : 0;
_options.push(_opt); _options.push(_opt);
} }
toolbar.loadStruct([{ toolbar.loadStruct([{
......
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