0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
Commit Graph

50 Commits

Author SHA1 Message Date
Yosuke Furukawa
a776a86859 querystring: Parse multiple separator characters
Fix querystring.parse to handle multiple separator characters

PR-URL: https://github.com/nodejs/node/pull/3807
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-13 10:13:35 -08:00
Roman Reiss
b5b8ff117c lib: don't use global Buffer
Port of https://github.com/joyent/node/pull/8603

The race condition present in the original PR didn't occur, so no
workaround was needed.

PR-URL: https://github.com/nodejs/io.js/pull/1794
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-06-11 20:24:44 +02:00
Yosuke Furukawa
19ffb5cf1c lib: fix eslint styles
PR-URL: https://github.com/iojs/io.js/pull/1539
Fixes: https://github.com/iojs/io.js/issues/1253
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
2015-05-09 12:10:02 +09:00
Jeremiah Senkpiel
c9aec2b716 querystring: fix broken stringifyPrimitive
stringifyPrimitive has always failed to stringify numbers since its
introduction in 422d3c9. This went uncaught due to encodeURIComponent's
string coercion.

Fixes: https://github.com/iojs/io.js/issues/1208
PR-URL: https://github.com/iojs/io.js/pull/1213
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Brian White <mscdex@mscdex.net>
2015-03-19 21:47:41 -04:00
Jeremiah Senkpiel
a89f5c2156 querystring: parse numbers correctly
Fixes a number parsing regression introduced in 85a92a3

Fixes: https://github.com/iojs/io.js/issues/1208
PR-URL: https://github.com/iojs/io.js/pull/1213
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Brian White <mscdex@mscdex.net>
2015-03-19 21:45:38 -04:00
Brian White
85a92a37ef querystring: optimize parse and stringify
parse optimizations:

* Move try-catch to separate function to keep entire function from
being deoptimized.
* Use key array lookup instead of using hasOwnProperty.
* Avoid decoding known empty strings.
* Avoid possibly unnecessary switch to slower decoder for values if
key decoding throws.

stringify optimizations:

* Use manual loop for default encoder instead of encodeURIComponent.
* Use string concatenation instead of joining an array of strings.
* Avoid caching result of typeof.

PR-URL: https://github.com/iojs/io.js/pull/847
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-03-15 23:11:38 -04:00
cjihrig
6ac8bdc0ab lib: reduce util.is*() usage
Many of the util.is*() methods used to check data types
simply compare against a single value or the result of
typeof. This commit replaces calls to these methods with
equivalent checks. This commit does not touch calls to the
more complex methods (isRegExp(), isDate(), etc.).

Fixes: https://github.com/iojs/io.js/issues/607
PR-URL: https://github.com/iojs/io.js/pull/647
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-31 23:47:29 -05:00
cjihrig
804e7aa9ab lib: use const to define constants
This commit replaces a number of var statements throughout
the lib code with const statements.

PR-URL: https://github.com/iojs/io.js/pull/541
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-21 16:21:31 -05:00
isaacs
3e1b1dd4a9 Remove excessive copyright/license boilerplate
The copyright and license notice is already in the LICENSE file.  There
is no justifiable reason to also require that it be included in every
file, since the individual files are not individually distributed except
as part of the entire package.
2015-01-12 15:30:28 -08:00
Ben Noordhuis
21130c7d6f lib: turn on strict mode
Turn on strict mode for the files in the lib/ directory.  It helps
catch bugs and can have a positive effect on performance.

PR-URL: https://github.com/node-forward/node/pull/64
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-11-22 17:23:30 +01:00
Timothy J Fontaine
7ca5af87a0 Merge remote-tracking branch 'upstream/v0.10' into v0.12
Conflicts:
	ChangeLog
	deps/v8/src/hydrogen.cc
	lib/http.js
	lib/querystring.js
	src/node_crypto.cc
	src/node_version.h
	test/simple/test-querystring.js
2014-09-16 17:48:09 -07:00
Tristan Berger
0f2956192c querystring: fix unescape override
Documentation states that `querystring.unescape` may be overridden to
replace unescaper during parsing. However, the function was only
being used as a fallback for when the native decoder throws (on a
malformed URL). This patch moves the call to the native function and
the try/catch around it into querystring.unescape then has the parser
always invoke it, so that an override will always be used.

Fixes #4055

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-08-27 13:49:16 +04:00
cjihrig
61ddad1314 querystring: do not add sep for empty array
Currently, stringification of an empty array outputs a single
separator character. This commit causes an empty array to output
the empty string.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-07-24 00:41:51 +04:00
fengmk2
4729202d1e querystring: custom encode and decode
Not all querystring are utf-8 encoding, make querystring can be used
to encode / decode `non-utf8` encoding string if necessary.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-05-22 08:21:55 -07:00
Yorkie
8d3bc88bbe querystring: remove name from stringify()
QueryString.stringify() allowed a fourth argument that was used as a
conditional in the return value, but was undocumented, not used by core
and always was always false/undefiend. So the argument and conditional
have been removed.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2013-12-30 11:41:37 -08:00
Trevor Norris
87cde44280 Revert "util: more strict check for bool/number/string"
This reverts commit 95ee84fabe.
2013-12-20 13:44:56 -08:00
Yorkie
95ee84fabe util: more strict check for bool/number/string 2013-12-18 17:58:02 +04:00
isaacs
22c68fdc1d src: Replace macros with util functions 2013-08-01 15:08:01 -07:00
Ben Noordhuis
0330bdf519 lib: macro-ify type checks
Increases the grep factor. Makes it easier to harmonize type checks
across the code base.
2013-07-24 21:49:35 +02:00
Mitar
e5b90a14b8 querystring: Removing unnecessary binding
Binding of `http_parser` in querystring isn't used anywhere and should
be removed.
2013-04-01 14:30:34 +04:00
isaacs
f105f2f2fd trivial: Doc typo and lint fix 2012-06-19 14:07:48 -07:00
Felix Böhm
3a5798b097 querystring: improved speed and code cleanup 2012-06-16 10:43:17 -07:00
isaacs
a811a4a130 Fix #3058 querystring: Fix incorrect handling of empty keys 2012-05-11 08:49:03 -07:00
isaacs
d3b8372615 lint, missed in QS speed merge 2012-02-22 20:58:24 -08:00
Brian White
5e3ca98155 Make QueryString.parse() even faster 2012-02-21 12:17:26 -08:00
isaacs
0cdf85e28d Lint all the JavaScripts. 2012-02-18 15:34:57 -08:00
isaacs
116835561d Merge remote-tracking branch 'ry/v0.6'
Conflicts:
	ChangeLog
	deps/v8/src/version.cc
	deps/v8/tools/gyp/v8.gyp
	doc/about/index.html
	doc/community/index.html
	doc/index.html
	doc/logos/index.html
	doc/template.html
	lib/path.js
	lib/querystring.js
	src/node_version.h
2012-02-06 15:43:21 -08:00
Philip Tellis
5166758927 Make QueryString.parse run faster
Use decodeURIComponent when appropriate, and only fall back to
querystring.decode if it throws, or if the character is a '+'.

Fix #2248
2012-02-01 16:04:01 -08:00
Fedor Indutny
23de33968f querystring: fix maxKeys = 0 is ignored 2012-01-16 16:36:24 +06:00
Fedor Indutny
8a98c2f1d8 http, querystring: added limits to prevent DoS 2012-01-16 02:45:05 +06:00
isaacs
e06ce7562c Fix #1707 hasOwnProperty usage
If hasOwnProperty is overridden, then calling `obj.hasOwnProperty(prop)`
can fail.  Any time a dictionary of user-generated items is built, we
cannot rely on hasOwnProperty being safe, so must call it from the
Object.prototype explicitly.
2011-09-15 10:54:08 -07:00
isaacs
98990b9779 Fix #1707 hasOwnProperty usage 2011-09-15 09:46:30 -07:00
isaacs
3210809d0a Fix #1497 querystring: Replace 'in' test with 'hasOwnProperty' 2011-08-11 15:31:29 -07:00
Ryan Dahl
55048cdf79 Update copyright headers 2011-03-14 17:37:05 -07:00
Jeremy Martin
6f726cf8c7 url.parse(url, true) defaults query field to {} 2010-12-20 13:48:44 -08:00
Ryan Dahl
e232f6e735 more lint 2010-12-01 20:28:28 -08:00
Ryan Dahl
6ff12c425e Add querystring.unescapeBuffer 2010-11-18 15:18:06 -08:00
Ryan Dahl
57d8172906 query-string unescape moved to js land 2010-11-18 15:12:31 -08:00
Peter Griess
422d3c93bc Get rid of PHP/Rails style parameter munging.
- Handle only the most basic of query string parsing and construction.
  Leave the rest (e.g. Rails/PHP behaviors) to modules higher up the
  stack, like Express.
2010-09-13 12:39:30 -07:00
cloudhead
fe3e419687 querystring.parse: handle undefined value properly 2010-08-05 10:46:28 -07:00
Micheil Smith
299671b731 querystring: Removing typecasting of numeric strings to numbers
The tests did not accurately test for a strict equality, meaning that the
number == to the string.
2010-07-19 11:07:08 -07:00
Jan Kassens
bb2acd5e75 querystring.stringify is now more solid
* handles NaN and Infinity
* works with arrays from other contexts
2010-07-19 10:53:32 -07:00
Dmitry Baranovskiy
f8ca6b383c Rewrote QueryString.parse to make it smaller and more effective.
Also added ability to parse foo.bar=4 equal to foo[bar]=4
Added tests for this as well
2010-06-29 23:52:42 -07:00
Dmitry Baranovskiy
8ec12339f5 Refactored isA, isBool, etc functions to use some of ES5 goodness. 2010-06-29 19:22:28 -07:00
isaacs
4ce100fa62 A replacement for decodeURIComponent that doesn't throw.
And add a few more tests.
2010-06-15 19:28:09 -07:00
Thomas Lee
a63ce5cd72 Allow callers to disable PHP/Rails style parameter mungeing in querystring.stringify 2010-04-28 16:18:48 -07:00
Tim Caswell
62d9852c3d Replace slow and broken for..in loops with faster for loops over the keys. 2010-04-12 10:34:35 -07:00
isaacs
57fbb627ca trailing whitespace fixes 2010-04-11 14:48:23 -07:00
Ryan Dahl
b9cd3363ef Bugfix in querystring 2010-03-05 17:07:02 -08:00
isaacs
7ff04c1f86 Add URL and QueryString modules, and tests for each.
Also, make a slight change from original on url-module to put the
spacePattern into the function.  On closer inspection, it turns out that the
nonlocal-var cost is higher than the compiling-a-regexp cost.

Also, documentation.
2010-01-04 21:03:54 -08:00