| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1b85989 commit d777da2
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,13 +43,12 @@ function ClientRequest(options, cb) { | |||
| 43 | 43 | if (self.agent && self.agent.protocol) | |
| 44 | 44 | expectedProtocol = self.agent.protocol; | |
| 45 | 45 | ||
| 46 | - if (options.path && / /.test(options.path)) { | ||
| 46 | + if (options.path && /[\u0000-\u0020]/.test(options.path)) { | ||
| 47 | 47 | // The actual regex is more like /[^A-Za-z0-9\-._~!$&'()*+,;=/:@]/ | |
| 48 | 48 | // with an additional rule for ignoring percentage-escaped characters | |
| 49 | 49 | // but that's a) hard to capture in a regular expression that performs | |
| 50 | - // well, and b) possibly too restrictive for real-world usage. That's | ||
| 51 | - // why it only scans for spaces because those are guaranteed to create | ||
| 52 | - // an invalid request. | ||
| 50 | + // well, and b) possibly too restrictive for real-world usage. | ||
| 51 | + // Restrict the filter to control characters and spaces. | ||
| 53 | 52 | throw new TypeError('Request path contains unescaped characters'); | |
| 54 | 53 | } else if (protocol !== expectedProtocol) { | |
| 55 | 54 | throw new Error('Protocol "' + protocol + '" not supported. ' + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,14 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - var common = require('../common'); | ||
| 3 | - var assert = require('assert'); | ||
| 4 | - var http = require('http'); | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const http = require('http'); | ||
| 5 | 5 | ||
| 6 | - assert.throws(function() { | ||
| 7 | - // Path with spaces in it should throw. | ||
| 8 | - http.get({ path: 'bad path' }, common.fail); | ||
| 9 | - }, /contains unescaped characters/); | ||
| 6 | + function* bad() { | ||
| 7 | + for (let i = 0; i <= 32; i += 1) | ||
| 8 | + yield 'bad' + String.fromCharCode(i) + 'path'; | ||
| 9 | + } | ||
| 10 | + | ||
| 11 | + for (const path of bad()) { | ||
| 12 | + assert.throws(() => http.get({ path }, common.fail), | ||
| 13 | + /contains unescaped characters/); | ||
| 14 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments