Skip to content

Commit

Permalink
Merge pull request #122 from AntSwordProject/v2.0.x
Browse files Browse the repository at this point in the history
Release v2.0.4
  • Loading branch information
Medicean authored Jan 21, 2019
2 parents ee48e5e + 16b7bcb commit 942c059
Show file tree
Hide file tree
Showing 68 changed files with 19,249 additions and 43 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.DS_*
antData
.vscode/
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,46 @@
> 有空会补补BUG、添添新功能。
> 同时也欢迎大家的参与!感谢各位朋友的支持! .TAT.
## 2019/01/21 `v(2.0.4)`

### 后端模块

* 优化返回包解码流程,增加自动猜解编码功能,该功能在中文较少时容易出错,出错了使用用户设置的字符编码

### 文件管理

* 编辑文件窗口将「编码」按钮替换为「用此编码打开」, 若打开文件之后乱码,不妨试试切换编码
* 新增「复制文件名」和「复制文件路径」功能,目标复制文件名或路径到剪贴板
* 编辑文件菜单可选择「标签打开」和「窗口打开」

### 虚拟终端

* 新增两条本地命令
* ashelp 列出所有本地命令
* ascmd 指定某个文件执行后续的命令. eg: ascmd /bin/bash 这样后续输入的命令将会使用 /bin/bash 来执行。注意仅对当前有效, 如果需要持久生效, 需要在shell配置中的「其它配置」设置。

### 系统设置

* 新增「默认设置」, 可在此配置文件管理默认编辑文件打开方式

### Other

* 新增 Python2 Custom CGI shell 示例

### BugFix

* 修复Linux中编码设置中找到不到路径的问题 (#117) thx @H1d3r
* 修复 Windows shell 盘符小写引起文件管理目录树错乱的 Bug
* 修复 ASP 文件创建失败和删除失败时提示

### 插件

#### ASRedis

* 新增「虚拟命令行」功能

![](https://i.loli.net/2019/01/16/5c3f2134dcd8f.png)

## 2018/12/25 `(v2.0.3)`

### 模块增强
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AntSword [![release](https://img.shields.io/badge/release-v2.0.3-blue.svg?style=flat-square)][url-release]
# AntSword [![release](https://img.shields.io/badge/release-v2.0.4-blue.svg?style=flat-square)][url-release]

> AntSword in your hands, no worries in your mind!
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 中国蚁剑 [![release](https://img.shields.io/badge/release-v2.0.3-blue.svg?style=flat-square)][url-release]
# 中国蚁剑 [![release](https://img.shields.io/badge/release-v2.0.4-blue.svg?style=flat-square)][url-release]

> 一剑在手,纵横无忧!
Expand Down
50 changes: 48 additions & 2 deletions modules/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

const fs = require('fs'),
iconv = require('iconv-lite'),
jschardet = require('jschardet'),
through = require('through'),
CONF = require('./config'),
superagent = require('superagent'),
Expand Down Expand Up @@ -135,14 +136,20 @@ class Request {
}
let buff = ret.hasOwnProperty('body') ? ret.body : new Buffer();
// 解码
let text = iconv.decode(buff, opts['encode']);
let text = "";
// 自动猜测编码
let encoding = detectEncoding(buff, {defaultEncoding:"unknown"});
logger.debug("detect encoding:", encoding);
encoding = encoding != "unknown" ? encoding : opts['encode'];
text = iconv.decode(buff, encoding);
if (err && text == "") {
return event.sender.send('request-error-' + opts['hash'], err);
};
// 回调数据
event.sender.send('request-' + opts['hash'], {
text: text,
buff: buff
buff: buff,
encoding: encoding
});
});
}
Expand Down Expand Up @@ -280,4 +287,43 @@ class Request {

}

/**
* 判断指定buffer对象的字符编码
* ref: https://github.com/LeoYuan/leoyuan.github.io/issues/25
* @param buffer
* @param options
* - defaultEncoding 指定默认编码集
* - minConfidence 指定可接受的最小confidence,如果判断结果小于此值,则用defaultEncoding
* - verbose 返回更加详细的字符编码数据
* @returns {*}
*/
function detectEncoding(buffer, options) {

options = options || {};
buffer = buffer || Buffer('');

var DEFAULT_ENCODING = 'GBK', MIN_CONFIDENCE = 0.96;
var verbose = options.verbose;
var defaultEncoding = options.defaultEncoding || DEFAULT_ENCODING;
var minConfidence = options.minConfidence || MIN_CONFIDENCE;
var ret = jschardet.detect(buffer), encoding = ret.encoding === 'ascii' ? 'utf-8' : ret.encoding,
confidence = ret.confidence;
// var VALID_ENCODINGS = ['gb2312', 'gbk', 'utf-8', 'big5', 'euc-kr','euc-jp'];

if (encoding === null || !iconv.encodingExists(encoding) || confidence < minConfidence) {
return verbose ? {
encoding: defaultEncoding,
oriEncoding: encoding,
confidence: confidence
} : defaultEncoding;
} else {
encoding = encoding.toUpperCase();
return verbose ? {
encoding: encoding,
oriEncoding: encoding,
confidence: confidence
} : encoding;
}
};

module.exports = Request;
2 changes: 2 additions & 0 deletions node_modules/jschardet/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions node_modules/jschardet/CONTRIBUTORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 942c059

Please sign in to comment.