fix(core): update

This commit is contained in:
Philipp Kunz 2019-10-10 18:14:07 +02:00
parent 8665464416
commit 8ff2a9d64a
6 changed files with 120 additions and 105 deletions

22
.gitignore vendored
View File

@ -1,4 +1,22 @@
.yarn/
pages/
.nogit/
# artifacts
coverage/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_web/
dist_serve/
dist_ts_web/
# custom

View File

@ -1,5 +1,5 @@
# gitzone standard
image: hosttoday/ht-docker-node:npmci
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
@ -38,19 +38,7 @@ snyk:
# test stage
# ====================
testLTS:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testSTABLE:
testStable:
stage: test
script:
- npmci npm prepare
@ -60,6 +48,18 @@ testSTABLE:
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- priv
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
release:
@ -78,19 +78,12 @@ release:
# ====================
codequality:
stage: metadata
image: docker:stable
allow_failure: true
services:
- docker:stable-dind
script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- docker
- priv
@ -106,13 +99,15 @@ trigger:
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
image: hosttoday/ht-docker-dbase:npmci
services:
- docker:stable-dind
stage: metadata
script:
- npmci command npm install -g typedoc typescript
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
- npmci command tsdoc
tags:
- docker
- notpriv

View File

@ -61,6 +61,6 @@ smartstring.indent.normalize(' somestring anotherstring', '>>>> '); //
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -38,5 +38,16 @@
"normalize-newline": "^3.0.0",
"randomatic": "^3.1.1",
"strip-indent": "^3.0.0"
}
}
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_web/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
]
}

View File

@ -11,4 +11,4 @@ tap.test('should state wether base64 string is valid', async () => {
expect(smartstring.type.isBase64('hi there')).to.be.false;
});
tap.start();
tap.start();

View File

@ -4,77 +4,68 @@ import * as base64 from './smartstring.base64';
export const isUtf8 = (stringArg: string) => {
const bytes = Buffer.from(stringArg);
let i = 0;
while(i < bytes.length)
{
if( (// ASCII
bytes[i] === 0x09 ||
bytes[i] === 0x0A ||
bytes[i] === 0x0D ||
(0x20 <= bytes[i] && bytes[i] <= 0x7E)
)
) {
i += 1;
continue;
}
if( (// non-overlong 2-byte
(0xC2 <= bytes[i] && bytes[i] <= 0xDF) &&
(0x80 <= bytes[i+1] && bytes[i+1] <= 0xBF)
)
) {
i += 2;
continue;
}
if( (// excluding overlongs
bytes[i] === 0xE0 &&
(0xA0 <= bytes[i + 1] && bytes[i + 1] <= 0xBF) &&
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xBF)
) ||
(// straight 3-byte
((0xE1 <= bytes[i] && bytes[i] <= 0xEC) ||
bytes[i] === 0xEE ||
bytes[i] === 0xEF) &&
(0x80 <= bytes[i + 1] && bytes[i+1] <= 0xBF) &&
(0x80 <= bytes[i+2] && bytes[i+2] <= 0xBF)
) ||
(// excluding surrogates
bytes[i] === 0xED &&
(0x80 <= bytes[i+1] && bytes[i+1] <= 0x9F) &&
(0x80 <= bytes[i+2] && bytes[i+2] <= 0xBF)
)
) {
i += 3;
continue;
}
if( (// planes 1-3
bytes[i] === 0xF0 &&
(0x90 <= bytes[i + 1] && bytes[i + 1] <= 0xBF) &&
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xBF) &&
(0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xBF)
) ||
(// planes 4-15
(0xF1 <= bytes[i] && bytes[i] <= 0xF3) &&
(0x80 <= bytes[i + 1] && bytes[i + 1] <= 0xBF) &&
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xBF) &&
(0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xBF)
) ||
(// plane 16
bytes[i] === 0xF4 &&
(0x80 <= bytes[i + 1] && bytes[i + 1] <= 0x8F) &&
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xBF) &&
(0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xBF)
)
) {
i += 4;
continue;
}
return false;
while (i < bytes.length) {
if (
// ASCII
bytes[i] === 0x09 ||
bytes[i] === 0x0a ||
bytes[i] === 0x0d ||
(0x20 <= bytes[i] && bytes[i] <= 0x7e)
) {
i += 1;
continue;
}
return true;
if (
// non-overlong 2-byte
0xc2 <= bytes[i] &&
bytes[i] <= 0xdf &&
(0x80 <= bytes[i + 1] && bytes[i + 1] <= 0xbf)
) {
i += 2;
continue;
}
if (
// excluding overlongs
(bytes[i] === 0xe0 &&
(0xa0 <= bytes[i + 1] && bytes[i + 1] <= 0xbf) &&
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xbf)) || // straight 3-byte
(((0xe1 <= bytes[i] && bytes[i] <= 0xec) || bytes[i] === 0xee || bytes[i] === 0xef) &&
(0x80 <= bytes[i + 1] && bytes[i + 1] <= 0xbf) &&
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xbf)) || // excluding surrogates
(bytes[i] === 0xed &&
(0x80 <= bytes[i + 1] && bytes[i + 1] <= 0x9f) &&
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xbf))
) {
i += 3;
continue;
}
if (
// planes 1-3
(bytes[i] === 0xf0 &&
(0x90 <= bytes[i + 1] && bytes[i + 1] <= 0xbf) &&
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xbf) &&
(0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xbf)) || // planes 4-15
(0xf1 <= bytes[i] &&
bytes[i] <= 0xf3 &&
(0x80 <= bytes[i + 1] && bytes[i + 1] <= 0xbf) &&
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xbf) &&
(0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xbf)) || // plane 16
(bytes[i] === 0xf4 &&
(0x80 <= bytes[i + 1] && bytes[i + 1] <= 0x8f) &&
(0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xbf) &&
(0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xbf))
) {
i += 4;
continue;
}
return false;
}
return true;
};
export const isBase64 = (stringArg: string) => {