better code injection handling for js

This commit is contained in:
wing328
2016-06-28 23:17:28 +08:00
parent acc28495e8
commit aec2f4e27c
1354 changed files with 313854 additions and 109 deletions

View File

@@ -0,0 +1 @@
test

View File

@@ -0,0 +1,5 @@
language: node_js
node_js:
- "0.10"
- 0.8
- 0.6

View File

@@ -0,0 +1,59 @@
[![Build Status][1]][2] [![dependency status][9]][10] [![dev dependency status][11]][12]
# extend() for Node.js <sup>[![Version Badge][8]][3]</sup>
`node-extend` is a port of the classic extend() method from jQuery. It behaves as you expect. It is simple, tried and true.
## Installation
This package is available on [npm][3] as: `extend`
``` sh
npm install extend
```
## Usage
**Syntax:** extend **(** [`deep`], `target`, `object1`, [`objectN`] **)**
*Extend one object with one or more others, returning the modified object.*
Keep in mind that the target object will be modified, and will be returned from extend().
If a boolean true is specified as the first argument, extend performs a deep copy, recursively copying any objects it finds. Otherwise, the copy will share structure with the original object(s).
Undefined properties are not copied. However, properties inherited from the object's prototype will be copied over.
### Arguments
* `deep` *Boolean* (optional)
If set, the merge becomes recursive (i.e. deep copy).
* `target` *Object*
The object to extend.
* `object1` *Object*
The object that will be merged into the first.
* `objectN` *Object* (Optional)
More objects to merge into the first.
## License
`node-extend` is licensed under the [MIT License][4].
## Acknowledgements
All credit to the jQuery authors for perfecting this amazing utility.
Ported to Node.js by [Stefan Thomas][5] with contributions by [Jonathan Buchanan][6] and [Jordan Harband][7].
[1]: https://travis-ci.org/justmoon/node-extend.png
[2]: https://travis-ci.org/justmoon/node-extend
[3]: https://npmjs.org/package/extend
[4]: http://opensource.org/licenses/MIT
[5]: https://github.com/justmoon
[6]: https://github.com/insin
[7]: https://github.com/ljharb
[8]: http://vb.teelaun.ch/justmoon/node-extend.svg
[9]: https://david-dm.org/justmoon/node-extend.png
[10]: https://david-dm.org/justmoon/node-extend
[11]: https://david-dm.org/justmoon/node-extend/dev-status.png
[12]: https://david-dm.org/justmoon/node-extend#info=devDependencies

View File

@@ -0,0 +1,78 @@
var hasOwn = Object.prototype.hasOwnProperty;
var toString = Object.prototype.toString;
function isPlainObject(obj) {
if (!obj || toString.call(obj) !== '[object Object]' || obj.nodeType || obj.setInterval)
return false;
var has_own_constructor = hasOwn.call(obj, 'constructor');
var has_is_property_of_method = hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
// Not own constructor property must be Object
if (obj.constructor && !has_own_constructor && !has_is_property_of_method)
return false;
// Own properties are enumerated firstly, so to speed up,
// if last one is own, then all properties are own.
var key;
for ( key in obj ) {}
return key === undefined || hasOwn.call( obj, key );
};
module.exports = function extend() {
var options, name, src, copy, copyIsArray, clone,
target = arguments[0] || {},
i = 1,
length = arguments.length,
deep = false;
// Handle a deep copy situation
if ( typeof target === "boolean" ) {
deep = target;
target = arguments[1] || {};
// skip the boolean and the target
i = 2;
}
// Handle case when target is a string or something (possible in deep copy)
if ( typeof target !== "object" && typeof target !== "function") {
target = {};
}
for ( ; i < length; i++ ) {
// Only deal with non-null/undefined values
if ( (options = arguments[ i ]) != null ) {
// Extend the base object
for ( name in options ) {
src = target[ name ];
copy = options[ name ];
// Prevent never-ending loop
if ( target === copy ) {
continue;
}
// Recurse if we're merging plain objects or arrays
if ( deep && copy && ( isPlainObject(copy) || (copyIsArray = Array.isArray(copy)) ) ) {
if ( copyIsArray ) {
copyIsArray = false;
clone = src && Array.isArray(src) ? src : [];
} else {
clone = src && isPlainObject(src) ? src : {};
}
// Never move original objects, clone them
target[ name ] = extend( deep, clone, copy );
// Don't bring in undefined values
} else if ( copy !== undefined ) {
target[ name ] = copy;
}
}
}
}
// Return the modified object
return target;
};

View File

@@ -0,0 +1,85 @@
{
"_args": [
[
"extend@1.2.1",
"/Users/williamcheng/Code/may2016/swagger-codegen/samples/client/petstore-security-test/javascript/node_modules/superagent"
]
],
"_from": "extend@1.2.1",
"_id": "extend@1.2.1",
"_inCache": true,
"_installable": true,
"_location": "/extend",
"_npmUser": {
"email": "ljharb@gmail.com",
"name": "ljharb"
},
"_npmVersion": "1.3.8",
"_phantomChildren": {},
"_requested": {
"name": "extend",
"raw": "extend@1.2.1",
"rawSpec": "1.2.1",
"scope": null,
"spec": "1.2.1",
"type": "version"
},
"_requiredBy": [
"/superagent"
],
"_resolved": "https://registry.npmjs.org/extend/-/extend-1.2.1.tgz",
"_shasum": "a0f5fd6cfc83a5fe49ef698d60ec8a624dd4576c",
"_shrinkwrap": null,
"_spec": "extend@1.2.1",
"_where": "/Users/williamcheng/Code/may2016/swagger-codegen/samples/client/petstore-security-test/javascript/node_modules/superagent",
"author": {
"email": "justmoon@members.fsf.org",
"name": "Stefan Thomas",
"url": "http://www.justmoon.net"
},
"bugs": {
"url": "https://github.com/justmoon/node-extend/issues"
},
"contributors": [
{
"name": "Jordan Harband",
"url": "https://github.com/ljharb"
}
],
"dependencies": {},
"description": "Port of jQuery.extend for Node.js",
"devDependencies": {
"tape": "~1.1.0"
},
"directories": {},
"dist": {
"shasum": "a0f5fd6cfc83a5fe49ef698d60ec8a624dd4576c",
"tarball": "https://registry.npmjs.org/extend/-/extend-1.2.1.tgz"
},
"keywords": [
"clone",
"extend",
"merge"
],
"main": "index",
"maintainers": [
{
"name": "justmoon",
"email": "justmoon@members.fsf.org"
},
{
"name": "ljharb",
"email": "ljharb@gmail.com"
}
],
"name": "extend",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "https://github.com/justmoon/node-extend.git"
},
"scripts": {
"test": "node test/index.js"
},
"version": "1.2.1"
}