Skip to content

Commit 606a612

Browse files
committed
Merge pull request #3 from node-modules/fix-dot-regex
fix: dot regex string
2 parents 7d4582d + ed3774a commit 606a612

File tree

7 files changed

+26
-79
lines changed

7 files changed

+26
-79
lines changed

.travis.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
sudo: false
12
language: node_js
23
node_js:
3-
- '0.11'
4+
- '5'
5+
- '4'
6+
- '0.12'
47
- '0.10'
5-
script: "make test-travis"
6-
after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"
8+
script:
9+
- 'npm run test-cov'
10+
after_script:
11+
- 'npm i codecov.io && cat ./coverage/coverage.json | ./node_modules/codecov.io/bin/codecov.io.js'

Makefile

Lines changed: 0 additions & 50 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,15 @@ jsonp-body
22
=======
33

44
[![NPM version][npm-image]][npm-url]
5-
[![node version][node-image]][node-url]
65
[![build status][travis-image]][travis-url]
76
[![Test coverage][coveralls-image]][coveralls-url]
8-
[![Gittip][gittip-image]][gittip-url]
97

108
[npm-image]: https://img.shields.io/npm/v/jsonp-body.svg?style=flat-square
119
[npm-url]: https://npmjs.org/package/jsonp-body
12-
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square
13-
[node-url]: http://nodejs.org/download/
1410
[travis-image]: https://img.shields.io/travis/node-modules/jsonp-body.svg?style=flat-square
1511
[travis-url]: https://travis-ci.org/node-modules/jsonp-body
1612
[coveralls-image]: https://img.shields.io/coveralls/node-modules/jsonp-body.svg?style=flat-square
1713
[coveralls-url]: https://coveralls.io/r/node-modules/jsonp-body?branch=master
18-
[gittip-image]: https://img.shields.io/gittip/fengmk2.svg?style=flat-square
19-
[gittip-url]: https://www.gittip.com/fengmk2/
20-
21-
![logo](https://raw.github.com/node-modules/jsonp-body/master/logo.png)
2214

2315
Helper to create more safe jsonp response body for [koa](http://koajs.com/) and other web framework.
2416

@@ -63,7 +55,7 @@ Get `obj` jsonp string response with `callback`.
6355

6456
(The MIT License)
6557

66-
Copyright (c) 2014 fengmk2 <[email protected]> and other contributors
58+
Copyright (c) 2014 - 2015 node-modules and other contributors
6759

6860
Permission is hereby granted, free of charge, to any person obtaining
6961
a copy of this software and associated documentation files (the

index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
/**!
2-
* jsonp-body - index.js
3-
*
4-
* Copyright(c) fengmk2 and other contributors.
1+
/**
2+
* Copyright(c) node-modules and other contributors.
53
* MIT Licensed
64
*
75
* Authors:
8-
* fengmk2 <[email protected]> (http://fengmk2.github.com)
6+
* fengmk2 <[email protected]> (http://fengmk2.com)
97
*/
108

119
'use strict';
@@ -41,7 +39,7 @@ function jsonp(obj, callback, options) {
4139
}
4240

4341
// Only allow "[","]","a-zA-Z0123456789_", "$" and "." characters.
44-
var cb = callback.replace(/[^\[\]\w$.]/g, '');
42+
var cb = callback.replace(/[^\[\]\w\$\.]+/g, '');
4543

4644
// the /**/ is a specific security mitigation for "Rosetta Flash JSONP abuse"
4745
// @see https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-4671

logo.png

-22.8 KB
Binary file not shown.

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
"description": "Helper to create more safe jsonp response body for koa and other web framework.",
55
"main": "index.js",
66
"scripts": {
7-
"test": "make test-all"
7+
"test": "mocha test/*.test.js",
8+
"test-cov": "istanbul cover _mocha -- test/*.test.js"
89
},
910
"dependencies": {
1011

1112
},
1213
"devDependencies": {
1314
"autod": "*",
1415
"contributors": "*",
15-
"istanbul-harmony": "*",
16+
"istanbul": "*",
1617
"jshint": "*",
1718
"mocha": "*",
18-
"should": "~4.2.1"
19+
"should": "7"
1920
},
2021
"homepage": "https://github.com/node-modules/jsonp-body",
2122
"repository": {
@@ -31,11 +32,12 @@
3132
"jsonp",
3233
"koa",
3334
"json",
34-
"CVE-2014-4671", "abusing-jsonp-with-rosetta-flash"
35+
"CVE-2014-4671",
36+
"abusing-jsonp-with-rosetta-flash"
3537
],
3638
"engines": {
3739
"node": ">= 0.10.0"
3840
},
39-
"author": "fengmk2 <[email protected]> (http://fengmk2.github.com)",
41+
"author": "fengmk2 <[email protected]> (http://fengmk2.com)",
4042
"license": "MIT"
4143
}

test/index.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
/**!
2-
* jsonp-body - test/index.test.js
3-
*
4-
* Copyright(c) fengmk2 and other contributors.
1+
/**
2+
* Copyright(c) node-modules and other contributors.
53
* MIT Licensed
64
*
75
* Authors:
8-
* fengmk2 <[email protected]> (http://fengmk2.github.com)
6+
* fengmk2 <[email protected]> (http://fengmk2.com)
97
*/
108

119
"use strict";
@@ -19,6 +17,8 @@ var jsonp = require('../');
1917

2018
describe('index.test.js', function () {
2119
it('should return with padding', function () {
20+
jsonp({foo: 'bar'}, 'f.f[1]$')
21+
.should.equal('/**/ typeof f.f[1]$ === \'function\' && f.f[1]$({"foo":"bar"});');
2222
jsonp({foo: 'bar'}, 'fn')
2323
.should.equal('/**/ typeof fn === \'function\' && fn({"foo":"bar"});');
2424
jsonp({foo: 'bar'}, ['fn'])
@@ -37,7 +37,7 @@ describe('index.test.js', function () {
3737
});
3838

3939
it('should replace unsafe characters', function () {
40-
jsonp({foo: 'bar'}, '~~~```fn---')
40+
jsonp({foo: 'bar'}, '~~~```fn---中文\u1231')
4141
.should.equal('/**/ typeof fn === \'function\' && fn({"foo":"bar"});');
4242
jsonp({foo: 'bar'}, ['fn哈哈\\!@#%^&*(){},?/ \tok'])
4343
.should.equal('/**/ typeof fnok === \'function\' && fnok({"foo":"bar"});');

0 commit comments

Comments
 (0)