From a9fa88972de3b92462ed4ac2e200906dee59b3ef Mon Sep 17 00:00:00 2001 From: wupengFEX Date: Tue, 16 Jan 2018 16:44:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BC=96=E7=A0=81case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/encoding/index.js | 2 +- test/encoding.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/encoding/index.js b/src/encoding/index.js index 93d4878..f97b203 100644 --- a/src/encoding/index.js +++ b/src/encoding/index.js @@ -1,4 +1,4 @@ -const jschardet = require('./fake-jschardet.js') +const jschardet = require('jschardet') const ERR = require('../error/dfn.json') const allowedEncoding = ['UTF-8', 'ascii'] const logger = require('../logger.js')('mip-validator:encoding') diff --git a/test/encoding.js b/test/encoding.js index 118811e..1c365f3 100644 --- a/test/encoding.js +++ b/test/encoding.js @@ -2,7 +2,9 @@ const chai = require('./chai.js') const expect = chai.expect const Validator = require('..') const asciiStr = 'hello' +const ERR = require('../src/error/dfn.json') const utf8Str = '\xc3\xa0\xc3\xad\xc3\xa0\xc3\xa7\xc3\xa3' +const big5Str = '\xa6\xb8\xb1\x60\xa5\xce\xb0\xea\xa6\x72\xbc\xd0\xb7\xc7\xa6\x72\xc5\xe9\xaa\xed' describe('encoding', function() { it('should accept ASCII', function() { @@ -15,4 +17,10 @@ describe('encoding', function() { var result = validator.validate(utf8Str) expect(result).to.have.lengthOf(0) }) + it('should reject Big5', function () { + var validator = Validator({}) + var result = validator.validate(big5Str) + expect(result).to.have.lengthOf(1) + expect(result[0].code).to.equal(ERR.DISALLOWED_ENCODING.code) + }) }) \ No newline at end of file From 31f67b0be4fa5d5c8b34d793284450ece9680926 Mon Sep 17 00:00:00 2001 From: wupengFEX Date: Tue, 16 Jan 2018 16:47:54 +0800 Subject: [PATCH 2/2] update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4663004..68f6ff9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mip-validator", - "version": "1.5.12", + "version": "1.5.13", "description": "MIP validator", "main": "index.js", "dependencies": {