diff --git a/.dirimages/archive.png b/.dirimages/archive.png
index 3ebc995..3a8886d 100644
Binary files a/.dirimages/archive.png and b/.dirimages/archive.png differ
diff --git a/.dirimages/audio.png b/.dirimages/audio.png
index 5b6d4c5..bf358f6 100644
Binary files a/.dirimages/audio.png and b/.dirimages/audio.png differ
diff --git a/.dirimages/bad.png b/.dirimages/bad.png
index 115fb0e..3f94cfb 100644
Binary files a/.dirimages/bad.png and b/.dirimages/bad.png differ
diff --git a/.dirimages/css.png b/.dirimages/css.png
index 753b7c4..030548a 100644
Binary files a/.dirimages/css.png and b/.dirimages/css.png differ
diff --git a/.dirimages/directory.png b/.dirimages/directory.png
index 9dcd620..4506365 100644
Binary files a/.dirimages/directory.png and b/.dirimages/directory.png differ
diff --git a/.dirimages/diskimage.png b/.dirimages/diskimage.png
index 4306ca2..db5018c 100644
Binary files a/.dirimages/diskimage.png and b/.dirimages/diskimage.png differ
diff --git a/.dirimages/fifo.png b/.dirimages/fifo.png
index 79a24f7..c6fbf9f 100644
Binary files a/.dirimages/fifo.png and b/.dirimages/fifo.png differ
diff --git a/.dirimages/font.png b/.dirimages/font.png
index 58942e9..a25104c 100644
Binary files a/.dirimages/font.png and b/.dirimages/font.png differ
diff --git a/.dirimages/html.png b/.dirimages/html.png
index 0bd2993..cf13a95 100644
Binary files a/.dirimages/html.png and b/.dirimages/html.png differ
diff --git a/.dirimages/hwdevice.png b/.dirimages/hwdevice.png
index 3310396..90f731e 100644
Binary files a/.dirimages/hwdevice.png and b/.dirimages/hwdevice.png differ
diff --git a/.dirimages/image.png b/.dirimages/image.png
index 5c9d726..1f78375 100644
Binary files a/.dirimages/image.png and b/.dirimages/image.png differ
diff --git a/.dirimages/important.png b/.dirimages/important.png
index b68e876..53e3a49 100644
Binary files a/.dirimages/important.png and b/.dirimages/important.png differ
diff --git a/.dirimages/javascript.png b/.dirimages/javascript.png
index 3392699..f264880 100644
Binary files a/.dirimages/javascript.png and b/.dirimages/javascript.png differ
diff --git a/.dirimages/other.png b/.dirimages/other.png
index 29c53a3..6cfcb97 100644
Binary files a/.dirimages/other.png and b/.dirimages/other.png differ
diff --git a/.dirimages/php.png b/.dirimages/php.png
index 93e9834..08c70dd 100644
Binary files a/.dirimages/php.png and b/.dirimages/php.png differ
diff --git a/.dirimages/return.png b/.dirimages/return.png
index 83e9a2a..b6d85db 100644
Binary files a/.dirimages/return.png and b/.dirimages/return.png differ
diff --git a/.dirimages/socket.png b/.dirimages/socket.png
index 19bc9ca..3e93c04 100644
Binary files a/.dirimages/socket.png and b/.dirimages/socket.png differ
diff --git a/.dirimages/text.png b/.dirimages/text.png
index fc4cd51..4823d89 100644
Binary files a/.dirimages/text.png and b/.dirimages/text.png differ
diff --git a/.dirimages/video.png b/.dirimages/video.png
index 8d44d54..988f8ca 100644
Binary files a/.dirimages/video.png and b/.dirimages/video.png differ
diff --git a/config.json b/config.json
index 564028d..1c9a20d 100644
--- a/config.json
+++ b/config.json
@@ -3,7 +3,7 @@
"port": 80,
"pubport": 80,
"page404": "404.html",
- "timestamp": 1701600932028,
+ "timestamp": 1709477722479,
"blacklist": [],
"nonStandardCodes": [],
"enableCompression": true,
@@ -58,5 +58,6 @@
"useWebRootServerSideScript": true,
"exposeModsInErrorPages": true,
"disableTrailingSlashRedirects": false,
- "environmentVariables": {}
+ "environmentVariables": {},
+ "allowDoubleSlashes": false
}
diff --git a/index.html b/index.html
index 42407ca..17e38c0 100644
--- a/index.html
+++ b/index.html
@@ -1,7 +1,7 @@
- If you see this page that means that the server is working properly. You can further configure the server and replace index.html and tests.html pages with custom ones.
- - Fixed bug with URLs beginning with multiple slashes being rewritten incorrectly.
+
+ - Updated tar and graceful-fs libraries.
+ - Added support for URLs with double slashes.
+ - Rewritten HTTP to HTTPS redirect functionality.
+ - Changed default directory listing icons.
-
- Tests
- Licenses
- SVR.JS status page
- More Information
-
-
+
+ Tests
+ Licenses
+ SVR.JS status page
+ SVR.JS documentation
+
diff --git a/licenses/index.html b/licenses/index.html
index cca5457..d9ede85 100644
--- a/licenses/index.html
+++ b/licenses/index.html
@@ -1,347 +1,349 @@
-
-
-
- SVR.JS 3.14.3 Licenses
-
-
-
-
-
- SVR.JS 3.14.3 Licenses
- SVR.JS 3.14.3
-
- MIT License
-
- Copyright (c) 2018-2024 SVR.JS
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
-
- Packages used by SVR.JS 3.14.3
-
-
License: MIT
-
-
- High-priority task queue for Node.js and browsers
-
-
-
-
License: MIT
-
-
- ASN.1 encoder and decoder
-
-
-
-
License: MIT
-
-
- RFC2560 structures for asn1.js
-
-
-
-
License: MIT
-
-
- RFC5280 extension structures for asn1.js
-
-
-
-
License: MIT
-
-
async (by Caolan McMahon)
-
-
- Higher-order functions and common patterns for asynchronous code
-
-
-
-
License: MIT
-
-
bn.js (by Fedor Indutny)
-
-
- Big number implementation in pure javascript
-
-
-
-
License: MIT
-
-
- Robustly `.call.bind()` a function
-
-
-
-
License: ISC
-
-
chownr (by Isaac Z. Schlueter)
-
-
- like `chown -R`
-
-
-
-
License: ISC
-
-
dezalgo (by Isaac Z. Schlueter)
-
-
- Contain async insanity so that the dark pony lord doesn't eat souls
-
-
-
-
License: MIT
-
-
- A node.js module for parsing form data, especially file uploads.
- Required by SVR.JS
-
-
-
-
License: ISC
-
-
- fs read and write streams based on minipass
- Patched to work with Bun
-
-
-
-
License: MIT
-
-
- Implementation of Function.prototype.bind
-
-
-
-
License: MIT
-
-
- Get and robustly cache all JS language-level intrinsics at first require time
-
-
-
-
License: ISC
-
-
- A drop-in replacement for fs, making various improvements.
- Required by SVR.JS.
-
-
-
-
License: MIT
-
-
has (by Thiago de Arruda)
-
-
- Object.prototype.hasOwnProperty.call shortcut
-
-
-
-
License: MIT
-
-
- Determine if the JS environment has Symbol support. Supports spec, or shams.
-
-
-
-
License: MIT
-
-
- A tiny (190B) and extremely fast utility to generate random IDs of fixed length
-
-
-
-
License: ISC
-
-
- Browser-friendly inheritance fully compatible with standard node.js inherits()
-
-
-
-
License: MIT
-
-
- Media Type Database
-
-
-
-
License: MIT
-
-
- The ultimate javascript content-type utility.
- Required by SVR.JS.
-
-
-
-
License: ISC
-
-
- minimalistic-assert ===
-
-
-
-
License: ISC
-
-
- minimal implementation of a PassThrough stream
-
-
-
-
License: MIT
-
-
- A small fast zlib stream built on
minipass and Node.js's zlib binding.
-
-
-
-
License: MIT
-
-
- Recursively mkdir, like `mkdir -p`
-
-
-
-
License: MIT
-
-
- string representations of objects in node and the browser
-
-
-
-
License: MIT
-
-
ocsp (by Fedor Indutny)
-
-
- OCSP Stapling implementation
- Required by SVR.JS.
-
-
-
-
License: ISC
-
-
once (by Isaac Z. Schlueter)
-
-
- Run a function exactly one time
-
-
-
-
License: BSD-3
-
-
- A querystring parser that supports nesting and arrays, with a depth limit
-
-
-
-
License: MIT
-
-
- Store information about any JS value in a side channel. Uses WeakMap if available.
-
-
-
-
License: MIT
-
-
- node-simple-lru-cache =====================
-
-
-
-
License: ISC
-
-
tar (by Isaac Z. Schlueter)
-
-
- tar for node
- Required by SVR.JS.
-
-
-
-
License: ISC
-
-
wrappy (by Isaac Z. Schlueter)
-
-
- Callback wrapping utility
-
-
-
-
License: ISC
-
-
yallist (by Isaac Z. Schlueter)
-
-
- Yet Another Linked List
-
-
-
-
-
-
+
+
+
+ SVR.JS 3.14.4 Licenses
+
+
+
+
+
+ SVR.JS 3.14.4 Licenses
+ SVR.JS 3.14.4
+
+ MIT License
+
+ Copyright (c) 2018-2024 SVR.JS
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+
+ Packages used by SVR.JS 3.14.4
+
+
+
License: MIT
+
+
+ High-priority task queue for Node.js and browsers
+
+
+
+
License: MIT
+
+
+ ASN.1 encoder and decoder
+
+
+
+
License: MIT
+
+
+ RFC2560 structures for asn1.js
+
+
+
+
License: MIT
+
+
+ RFC5280 extension structures for asn1.js
+
+
+
+
License: MIT
+
+
async (by Caolan McMahon)
+
+
+ Higher-order functions and common patterns for asynchronous code
+
+
+
+
License: MIT
+
+
bn.js (by Fedor Indutny)
+
+
+ Big number implementation in pure javascript
+
+
+
+
License: MIT
+
+
+ Robustly `.call.bind()` a function
+
+
+
+
License: ISC
+
+
chownr (by Isaac Z. Schlueter)
+
+
+ like `chown -R`
+
+
+
+
License: ISC
+
+
dezalgo (by Isaac Z. Schlueter)
+
+
+ Contain async insanity so that the dark pony lord doesn't eat souls
+
+
+
+
License: MIT
+
+
+ A node.js module for parsing form data, especially file uploads.
+ Required by SVR.JS
+
+
+
+
License: ISC
+
+
+ fs read and write streams based on minipass
+ Patched to work with Bun
+
+
+
+
License: MIT
+
+
+ Implementation of Function.prototype.bind
+
+
+
+
License: MIT
+
+
+ Get and robustly cache all JS language-level intrinsics at first require time
+
+
+
+
License: ISC
+
+
+ A drop-in replacement for fs, making various improvements.
+ Required by SVR.JS.
+
+
+
+
License: MIT
+
+
has (by Thiago de Arruda)
+
+
+ Object.prototype.hasOwnProperty.call shortcut
+
+
+
+
License: MIT
+
+
+ Determine if the JS environment has Symbol support. Supports spec, or shams.
+
+
+
+
License: MIT
+
+
+ A tiny (190B) and extremely fast utility to generate random IDs of fixed length
+
+
+
+
License: ISC
+
+
+ Browser-friendly inheritance fully compatible with standard node.js inherits()
+
+
+
+
License: MIT
+
+
+ Media Type Database
+
+
+
+
License: MIT
+
+
+ The ultimate javascript content-type utility.
+ Required by SVR.JS.
+
+
+
+
License: ISC
+
+
+ minimalistic-assert ===
+
+
+
+
License: ISC
+
+
+ minimal implementation of a PassThrough stream
+
+
+
+
License: MIT
+
+
+ A small fast zlib stream built on
minipass and Node.js's zlib binding.
+
+
+
+
License: MIT
+
+
+ Recursively mkdir, like `mkdir -p`
+
+
+
+
License: MIT
+
+
+ string representations of objects in node and the browser
+
+
+
+
License: MIT
+
+
ocsp (by Fedor Indutny)
+
+
+ OCSP Stapling implementation
+ Required by SVR.JS.
+
+
+
+
License: ISC
+
+
once (by Isaac Z. Schlueter)
+
+
+ Run a function exactly one time
+
+
+
+
License: BSD-3
+
+
+ A querystring parser that supports nesting and arrays, with a depth limit
+
+
+
+
License: MIT
+
+
+ Store information about any JS value in a side channel. Uses WeakMap if available.
+
+
+
+
License: MIT
+
+
+ node-simple-lru-cache =====================
+
+
+
+
License: ISC
+
+
tar (by Isaac Z. Schlueter)
+
+
+ tar for node
+ Required by SVR.JS.
+
+
+
+
License: ISC
+
+
wrappy (by Isaac Z. Schlueter)
+
+
+ Callback wrapping utility
+
+
+
+
License: ISC
+
+
yallist (by Isaac Z. Schlueter)
+
+
+ Yet Another Linked List
+
+
+
+
+
+
+
diff --git a/node_modules/formidable/package.json b/node_modules/formidable/package.json
index 6d3be2a..adbe60a 100644
--- a/node_modules/formidable/package.json
+++ b/node_modules/formidable/package.json
@@ -1,36 +1,33 @@
{
- "_from": "formidable@2",
- "_id": "formidable@2.1.2",
- "_inBundle": false,
- "_integrity": "sha512-CM3GuJ57US06mlpQ47YcunuUZ9jpm8Vx+P2CGt2j7HpgkKZO/DJYQ0Bobim8G6PFQmK5lOqOOdUXboU+h73A4g==",
- "_location": "/formidable",
- "_phantomChildren": {},
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "formidable@2",
- "name": "formidable",
- "escapedName": "formidable",
- "rawSpec": "2",
- "saveSpec": null,
- "fetchSpec": "2"
- },
- "_requiredBy": [
- "#USER",
- "/"
+ "name": "formidable",
+ "version": "2.1.2",
+ "license": "MIT",
+ "description": "A node.js module for parsing form data, especially file uploads.",
+ "homepage": "https://github.com/node-formidable/formidable",
+ "funding": "https://ko-fi.com/tunnckoCore/commissions",
+ "repository": "node-formidable/formidable",
+ "main": "./src/index.js",
+ "files": [
+ "src"
],
- "_resolved": "https://registry.npmjs.org/formidable/-/formidable-2.1.2.tgz",
- "_shasum": "fa973a2bec150e4ce7cac15589d7a25fc30ebd89",
- "_spec": "formidable@2",
- "_where": "/home/ubuntu/forbidden",
- "bugs": {
- "url": "https://github.com/node-formidable/formidable/issues"
+ "publishConfig": {
+ "access": "public",
+ "tag": "v2-latest"
},
- "bundleDependencies": false,
- "commitlint": {
- "extends": [
- "@commitlint/config-conventional"
- ]
+ "scripts": {
+ "bench": "node benchmark",
+ "fmt": "yarn run fmt:prepare '**/*'",
+ "fmt:prepare": "prettier --write",
+ "lint": "yarn run lint:prepare .",
+ "lint:prepare": "eslint --cache --fix --quiet --format codeframe",
+ "reinstall": "del-cli ./node_modules ./yarn.lock",
+ "postreinstall": "yarn setup",
+ "setup": "yarn",
+ "pretest": "del-cli ./test/tmp && make-dir ./test/tmp",
+ "test": "jest --coverage",
+ "pretest:ci": "yarn run pretest",
+ "test:ci": "nyc jest --coverage",
+ "test:jest": "jest --coverage"
},
"dependencies": {
"dezalgo": "^1.0.4",
@@ -38,8 +35,6 @@
"once": "^1.4.0",
"qs": "^6.11.0"
},
- "deprecated": false,
- "description": "A node.js module for parsing form data, especially file uploads.",
"devDependencies": {
"@commitlint/cli": "8.3.5",
"@commitlint/config-conventional": "8.3.4",
@@ -62,17 +57,6 @@
"request": "2.88.2",
"supertest": "4.0.2"
},
- "files": [
- "src"
- ],
- "funding": "https://ko-fi.com/tunnckoCore/commissions",
- "homepage": "https://github.com/node-formidable/formidable",
- "husky": {
- "hooks": {
- "pre-commit": "git status --porcelain && yarn lint-staged",
- "commit-msg": "yarn commitlint -E HUSKY_GIT_PARAMS"
- }
- },
"jest": {
"verbose": true
},
@@ -86,7 +70,17 @@
"ulpoad",
"file"
],
- "license": "MIT",
+ "husky": {
+ "hooks": {
+ "pre-commit": "git status --porcelain && yarn lint-staged",
+ "commit-msg": "yarn commitlint -E HUSKY_GIT_PARAMS"
+ }
+ },
+ "commitlint": {
+ "extends": [
+ "@commitlint/config-conventional"
+ ]
+ },
"lint-staged": {
"!*.{js,jsx,ts,tsx}": [
"yarn run fmt:prepare"
@@ -95,36 +89,10 @@
"yarn run lint"
]
},
- "main": "./src/index.js",
- "name": "formidable",
- "publishConfig": {
- "access": "public",
- "tag": "v2-latest"
- },
"renovate": {
"extends": [
"@tunnckocore",
":pinAllExceptPeerDependencies"
]
- },
- "repository": {
- "type": "git",
- "url": "git+https://github.com/node-formidable/formidable.git"
- },
- "scripts": {
- "bench": "node benchmark",
- "fmt": "yarn run fmt:prepare '**/*'",
- "fmt:prepare": "prettier --write",
- "lint": "yarn run lint:prepare .",
- "lint:prepare": "eslint --cache --fix --quiet --format codeframe",
- "postreinstall": "yarn setup",
- "pretest": "del-cli ./test/tmp && make-dir ./test/tmp",
- "pretest:ci": "yarn run pretest",
- "reinstall": "del-cli ./node_modules ./yarn.lock",
- "setup": "yarn",
- "test": "jest --coverage",
- "test:ci": "nyc jest --coverage",
- "test:jest": "jest --coverage"
- },
- "version": "2.1.2"
+ }
}
diff --git a/node_modules/graceful-fs/LICENSE b/node_modules/graceful-fs/LICENSE
old mode 100755
new mode 100644
index 9d2c803..e906a25
--- a/node_modules/graceful-fs/LICENSE
+++ b/node_modules/graceful-fs/LICENSE
@@ -1,6 +1,6 @@
The ISC License
-Copyright (c) Isaac Z. Schlueter, Ben Noordhuis, and Contributors
+Copyright (c) 2011-2022 Isaac Z. Schlueter, Ben Noordhuis, and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
diff --git a/node_modules/graceful-fs/README.md b/node_modules/graceful-fs/README.md
old mode 100755
new mode 100644
index 5273a50..82d6e4d
--- a/node_modules/graceful-fs/README.md
+++ b/node_modules/graceful-fs/README.md
@@ -30,9 +30,19 @@ the directory.
var fs = require('graceful-fs')
// now go and do stuff with it...
-fs.readFileSync('some-file-or-whatever')
+fs.readFile('some-file-or-whatever', (err, data) => {
+ // Do stuff here.
+})
```
+## Sync methods
+
+This module cannot intercept or handle `EMFILE` or `ENFILE` errors from sync
+methods. If you use sync methods which open file descriptors then you are
+responsible for dealing with any errors.
+
+This is a known limitation, not a bug.
+
## Global Patching
If you want to patch the global fs module (or any other fs-like
diff --git a/node_modules/graceful-fs/clone.js b/node_modules/graceful-fs/clone.js
old mode 100755
new mode 100644
index 028356c..dff3cc8
--- a/node_modules/graceful-fs/clone.js
+++ b/node_modules/graceful-fs/clone.js
@@ -2,12 +2,16 @@
module.exports = clone
+var getPrototypeOf = Object.getPrototypeOf || function (obj) {
+ return obj.__proto__
+}
+
function clone (obj) {
if (obj === null || typeof obj !== 'object')
return obj
if (obj instanceof Object)
- var copy = { __proto__: obj.__proto__ }
+ var copy = { __proto__: getPrototypeOf(obj) }
else
var copy = Object.create(null)
diff --git a/node_modules/graceful-fs/graceful-fs.js b/node_modules/graceful-fs/graceful-fs.js
old mode 100755
new mode 100644
index de3df47..8d5b89e
--- a/node_modules/graceful-fs/graceful-fs.js
+++ b/node_modules/graceful-fs/graceful-fs.js
@@ -54,7 +54,7 @@ if (!fs[gracefulQueue]) {
return fs$close.call(fs, fd, function (err) {
// This function uses the graceful-fs shared queue
if (!err) {
- retry()
+ resetQueue()
}
if (typeof cb === 'function')
@@ -72,7 +72,7 @@ if (!fs[gracefulQueue]) {
function closeSync (fd) {
// This function uses the graceful-fs shared queue
fs$closeSync.apply(fs, arguments)
- retry()
+ resetQueue()
}
Object.defineProperty(closeSync, previousSymbol, {
@@ -114,14 +114,13 @@ function patch (fs) {
return go$readFile(path, options, cb)
- function go$readFile (path, options, cb) {
+ function go$readFile (path, options, cb, startTime) {
return fs$readFile(path, options, function (err) {
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$readFile, [path, options, cb]])
+ enqueue([go$readFile, [path, options, cb], err, startTime || Date.now(), Date.now()])
else {
if (typeof cb === 'function')
cb.apply(this, arguments)
- retry()
}
})
}
@@ -135,14 +134,13 @@ function patch (fs) {
return go$writeFile(path, data, options, cb)
- function go$writeFile (path, data, options, cb) {
+ function go$writeFile (path, data, options, cb, startTime) {
return fs$writeFile(path, data, options, function (err) {
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$writeFile, [path, data, options, cb]])
+ enqueue([go$writeFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()])
else {
if (typeof cb === 'function')
cb.apply(this, arguments)
- retry()
}
})
}
@@ -157,14 +155,35 @@ function patch (fs) {
return go$appendFile(path, data, options, cb)
- function go$appendFile (path, data, options, cb) {
+ function go$appendFile (path, data, options, cb, startTime) {
return fs$appendFile(path, data, options, function (err) {
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$appendFile, [path, data, options, cb]])
+ enqueue([go$appendFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()])
+ else {
+ if (typeof cb === 'function')
+ cb.apply(this, arguments)
+ }
+ })
+ }
+ }
+
+ var fs$copyFile = fs.copyFile
+ if (fs$copyFile)
+ fs.copyFile = copyFile
+ function copyFile (src, dest, flags, cb) {
+ if (typeof flags === 'function') {
+ cb = flags
+ flags = 0
+ }
+ return go$copyFile(src, dest, flags, cb)
+
+ function go$copyFile (src, dest, flags, cb, startTime) {
+ return fs$copyFile(src, dest, flags, function (err) {
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
+ enqueue([go$copyFile, [src, dest, flags, cb], err, startTime || Date.now(), Date.now()])
else {
if (typeof cb === 'function')
cb.apply(this, arguments)
- retry()
}
})
}
@@ -172,36 +191,46 @@ function patch (fs) {
var fs$readdir = fs.readdir
fs.readdir = readdir
+ var noReaddirOptionVersions = /^v[0-5]\./
function readdir (path, options, cb) {
- var args = [path]
- if (typeof options !== 'function') {
- args.push(options)
- } else {
- cb = options
- }
- args.push(go$readdir$cb)
+ if (typeof options === 'function')
+ cb = options, options = null
- return go$readdir(args)
+ var go$readdir = noReaddirOptionVersions.test(process.version)
+ ? function go$readdir (path, options, cb, startTime) {
+ return fs$readdir(path, fs$readdirCallback(
+ path, options, cb, startTime
+ ))
+ }
+ : function go$readdir (path, options, cb, startTime) {
+ return fs$readdir(path, options, fs$readdirCallback(
+ path, options, cb, startTime
+ ))
+ }
- function go$readdir$cb (err, files) {
- if (files && files.sort)
- files.sort()
+ return go$readdir(path, options, cb)
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$readdir, [args]])
+ function fs$readdirCallback (path, options, cb, startTime) {
+ return function (err, files) {
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
+ enqueue([
+ go$readdir,
+ [path, options, cb],
+ err,
+ startTime || Date.now(),
+ Date.now()
+ ])
+ else {
+ if (files && files.sort)
+ files.sort()
- else {
- if (typeof cb === 'function')
- cb.apply(this, arguments)
- retry()
+ if (typeof cb === 'function')
+ cb.call(this, err, files)
+ }
}
}
}
- function go$readdir (args) {
- return fs$readdir.apply(fs, args)
- }
-
if (process.version.substr(0, 4) === 'v0.8') {
var legStreams = legacy(fs)
ReadStream = legStreams.ReadStream
@@ -324,14 +353,13 @@ function patch (fs) {
return go$open(path, flags, mode, cb)
- function go$open (path, flags, mode, cb) {
+ function go$open (path, flags, mode, cb, startTime) {
return fs$open(path, flags, mode, function (err, fd) {
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$open, [path, flags, mode, cb]])
+ enqueue([go$open, [path, flags, mode, cb], err, startTime || Date.now(), Date.now()])
else {
if (typeof cb === 'function')
cb.apply(this, arguments)
- retry()
}
})
}
@@ -343,12 +371,78 @@ function patch (fs) {
function enqueue (elem) {
debug('ENQUEUE', elem[0].name, elem[1])
fs[gracefulQueue].push(elem)
+ retry()
+}
+
+// keep track of the timeout between retry() calls
+var retryTimer
+
+// reset the startTime and lastTime to now
+// this resets the start of the 60 second overall timeout as well as the
+// delay between attempts so that we'll retry these jobs sooner
+function resetQueue () {
+ var now = Date.now()
+ for (var i = 0; i < fs[gracefulQueue].length; ++i) {
+ // entries that are only a length of 2 are from an older version, don't
+ // bother modifying those since they'll be retried anyway.
+ if (fs[gracefulQueue][i].length > 2) {
+ fs[gracefulQueue][i][3] = now // startTime
+ fs[gracefulQueue][i][4] = now // lastTime
+ }
+ }
+ // call retry to make sure we're actively processing the queue
+ retry()
}
function retry () {
+ // clear the timer and remove it to help prevent unintended concurrency
+ clearTimeout(retryTimer)
+ retryTimer = undefined
+
+ if (fs[gracefulQueue].length === 0)
+ return
+
var elem = fs[gracefulQueue].shift()
- if (elem) {
- debug('RETRY', elem[0].name, elem[1])
- elem[0].apply(null, elem[1])
+ var fn = elem[0]
+ var args = elem[1]
+ // these items may be unset if they were added by an older graceful-fs
+ var err = elem[2]
+ var startTime = elem[3]
+ var lastTime = elem[4]
+
+ // if we don't have a startTime we have no way of knowing if we've waited
+ // long enough, so go ahead and retry this item now
+ if (startTime === undefined) {
+ debug('RETRY', fn.name, args)
+ fn.apply(null, args)
+ } else if (Date.now() - startTime >= 60000) {
+ // it's been more than 60 seconds total, bail now
+ debug('TIMEOUT', fn.name, args)
+ var cb = args.pop()
+ if (typeof cb === 'function')
+ cb.call(null, err)
+ } else {
+ // the amount of time between the last attempt and right now
+ var sinceAttempt = Date.now() - lastTime
+ // the amount of time between when we first tried, and when we last tried
+ // rounded up to at least 1
+ var sinceStart = Math.max(lastTime - startTime, 1)
+ // backoff. wait longer than the total time we've been retrying, but only
+ // up to a maximum of 100ms
+ var desiredDelay = Math.min(sinceStart * 1.2, 100)
+ // it's been long enough since the last retry, do it again
+ if (sinceAttempt >= desiredDelay) {
+ debug('RETRY', fn.name, args)
+ fn.apply(null, args.concat([startTime]))
+ } else {
+ // if we can't do this job yet, push it to the end of the queue
+ // and let the next iteration check again
+ fs[gracefulQueue].push(elem)
+ }
+ }
+
+ // schedule our next run if one isn't already scheduled
+ if (retryTimer === undefined) {
+ retryTimer = setTimeout(retry, 0)
}
}
diff --git a/node_modules/graceful-fs/legacy-streams.js b/node_modules/graceful-fs/legacy-streams.js
old mode 100755
new mode 100644
diff --git a/node_modules/graceful-fs/package.json b/node_modules/graceful-fs/package.json
old mode 100755
new mode 100644
index 0923692..87babf0
--- a/node_modules/graceful-fs/package.json
+++ b/node_modules/graceful-fs/package.json
@@ -1,52 +1,22 @@
{
- "_from": "graceful-fs",
- "_id": "graceful-fs@4.2.4",
- "_inBundle": false,
- "_integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==",
- "_location": "/graceful-fs",
- "_phantomChildren": {},
- "_requested": {
- "type": "tag",
- "registry": true,
- "raw": "graceful-fs",
- "name": "graceful-fs",
- "escapedName": "graceful-fs",
- "rawSpec": "",
- "saveSpec": null,
- "fetchSpec": "latest"
- },
- "_requiredBy": [
- "#USER",
- "/"
- ],
- "_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz",
- "_shasum": "2256bde14d3632958c465ebc96dc467ca07a29fb",
- "_spec": "graceful-fs",
- "_where": "/media/serveradmin/Server/developement",
- "bugs": {
- "url": "https://github.com/isaacs/node-graceful-fs/issues"
- },
- "bundleDependencies": false,
- "dependencies": {},
- "deprecated": false,
+ "name": "graceful-fs",
"description": "A drop-in replacement for fs, making various improvements.",
- "devDependencies": {
- "import-fresh": "^2.0.0",
- "mkdirp": "^0.5.0",
- "rimraf": "^2.2.8",
- "tap": "^12.7.0"
+ "version": "4.2.11",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/isaacs/node-graceful-fs"
},
+ "main": "graceful-fs.js",
"directories": {
"test": "test"
},
- "files": [
- "fs.js",
- "graceful-fs.js",
- "legacy-streams.js",
- "polyfills.js",
- "clone.js"
- ],
- "homepage": "https://github.com/isaacs/node-graceful-fs#readme",
+ "scripts": {
+ "preversion": "npm test",
+ "postversion": "npm publish",
+ "postpublish": "git push origin --follow-tags",
+ "test": "nyc --silent node test.js | tap -c -",
+ "posttest": "nyc report"
+ },
"keywords": [
"fs",
"module",
@@ -64,17 +34,20 @@
"EACCESS"
],
"license": "ISC",
- "main": "graceful-fs.js",
- "name": "graceful-fs",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/isaacs/node-graceful-fs.git"
+ "devDependencies": {
+ "import-fresh": "^2.0.0",
+ "mkdirp": "^0.5.0",
+ "rimraf": "^2.2.8",
+ "tap": "^16.3.4"
},
- "scripts": {
- "postpublish": "git push origin --follow-tags",
- "postversion": "npm publish",
- "preversion": "npm test",
- "test": "node test.js | tap -"
- },
- "version": "4.2.4"
+ "files": [
+ "fs.js",
+ "graceful-fs.js",
+ "legacy-streams.js",
+ "polyfills.js",
+ "clone.js"
+ ],
+ "tap": {
+ "reporter": "classic"
+ }
}
diff --git a/node_modules/graceful-fs/polyfills.js b/node_modules/graceful-fs/polyfills.js
old mode 100755
new mode 100644
index a5808d2..453f1a9
--- a/node_modules/graceful-fs/polyfills.js
+++ b/node_modules/graceful-fs/polyfills.js
@@ -14,10 +14,14 @@ try {
process.cwd()
} catch (er) {}
-var chdir = process.chdir
-process.chdir = function(d) {
- cwd = null
- chdir.call(process, d)
+// This check is needed until node.js 12 is required
+if (typeof process.chdir === 'function') {
+ var chdir = process.chdir
+ process.chdir = function (d) {
+ cwd = null
+ chdir.call(process, d)
+ }
+ if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir)
}
module.exports = patch
@@ -67,13 +71,13 @@ function patch (fs) {
fs.lstatSync = statFixSync(fs.lstatSync)
// if lchmod/lchown do not exist, then make them no-ops
- if (!fs.lchmod) {
+ if (fs.chmod && !fs.lchmod) {
fs.lchmod = function (path, mode, cb) {
if (cb) process.nextTick(cb)
}
fs.lchmodSync = function () {}
}
- if (!fs.lchown) {
+ if (fs.chown && !fs.lchown) {
fs.lchown = function (path, uid, gid, cb) {
if (cb) process.nextTick(cb)
}
@@ -90,32 +94,38 @@ function patch (fs) {
// CPU to a busy looping process, which can cause the program causing the lock
// contention to be starved of CPU by node, so the contention doesn't resolve.
if (platform === "win32") {
- fs.rename = (function (fs$rename) { return function (from, to, cb) {
- var start = Date.now()
- var backoff = 0;
- fs$rename(from, to, function CB (er) {
- if (er
- && (er.code === "EACCES" || er.code === "EPERM")
- && Date.now() - start < 60000) {
- setTimeout(function() {
- fs.stat(to, function (stater, st) {
- if (stater && stater.code === "ENOENT")
- fs$rename(from, to, CB);
- else
- cb(er)
- })
- }, backoff)
- if (backoff < 100)
- backoff += 10;
- return;
- }
- if (cb) cb(er)
- })
- }})(fs.rename)
+ fs.rename = typeof fs.rename !== 'function' ? fs.rename
+ : (function (fs$rename) {
+ function rename (from, to, cb) {
+ var start = Date.now()
+ var backoff = 0;
+ fs$rename(from, to, function CB (er) {
+ if (er
+ && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY")
+ && Date.now() - start < 60000) {
+ setTimeout(function() {
+ fs.stat(to, function (stater, st) {
+ if (stater && stater.code === "ENOENT")
+ fs$rename(from, to, CB);
+ else
+ cb(er)
+ })
+ }, backoff)
+ if (backoff < 100)
+ backoff += 10;
+ return;
+ }
+ if (cb) cb(er)
+ })
+ }
+ if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename)
+ return rename
+ })(fs.rename)
}
// if read() returns EAGAIN, then just try it again.
- fs.read = (function (fs$read) {
+ fs.read = typeof fs.read !== 'function' ? fs.read
+ : (function (fs$read) {
function read (fd, buffer, offset, length, position, callback_) {
var callback
if (callback_ && typeof callback_ === 'function') {
@@ -132,11 +142,12 @@ function patch (fs) {
}
// This ensures `util.promisify` works as it does for native `fs.read`.
- read.__proto__ = fs$read
+ if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read)
return read
})(fs.read)
- fs.readSync = (function (fs$readSync) { return function (fd, buffer, offset, length, position) {
+ fs.readSync = typeof fs.readSync !== 'function' ? fs.readSync
+ : (function (fs$readSync) { return function (fd, buffer, offset, length, position) {
var eagCounter = 0
while (true) {
try {
@@ -195,7 +206,7 @@ function patch (fs) {
}
function patchLutimes (fs) {
- if (constants.hasOwnProperty("O_SYMLINK")) {
+ if (constants.hasOwnProperty("O_SYMLINK") && fs.futimes) {
fs.lutimes = function (path, at, mt, cb) {
fs.open(path, constants.O_SYMLINK, function (er, fd) {
if (er) {
@@ -229,7 +240,7 @@ function patch (fs) {
return ret
}
- } else {
+ } else if (fs.futimes) {
fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb) }
fs.lutimesSync = function () {}
}
@@ -306,8 +317,10 @@ function patch (fs) {
return function (target, options) {
var stats = options ? orig.call(fs, target, options)
: orig.call(fs, target)
- if (stats.uid < 0) stats.uid += 0x100000000
- if (stats.gid < 0) stats.gid += 0x100000000
+ if (stats) {
+ if (stats.uid < 0) stats.uid += 0x100000000
+ if (stats.gid < 0) stats.gid += 0x100000000
+ }
return stats;
}
}
diff --git a/node_modules/mime-db/package.json b/node_modules/mime-db/package.json
index 453259a..32c14b8 100644
--- a/node_modules/mime-db/package.json
+++ b/node_modules/mime-db/package.json
@@ -1,49 +1,23 @@
{
- "_from": "mime-db@1.52.0",
- "_id": "mime-db@1.52.0",
- "_inBundle": false,
- "_integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
- "_location": "/mime-db",
- "_phantomChildren": {},
- "_requested": {
- "type": "version",
- "registry": true,
- "raw": "mime-db@1.52.0",
- "name": "mime-db",
- "escapedName": "mime-db",
- "rawSpec": "1.52.0",
- "saveSpec": null,
- "fetchSpec": "1.52.0"
- },
- "_requiredBy": [
- "/mime-types"
- ],
- "_resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
- "_shasum": "bbabcdc02859f4987301c856e3387ce5ec43bf70",
- "_spec": "mime-db@1.52.0",
- "_where": "/home/ubuntu/formidable/node_modules/mime-types",
- "bugs": {
- "url": "https://github.com/jshttp/mime-db/issues"
- },
- "bundleDependencies": false,
- "contributors": [
- {
- "name": "Douglas Christopher Wilson",
- "email": "doug@somethingdoug.com"
- },
- {
- "name": "Jonathan Ong",
- "email": "me@jongleberry.com",
- "url": "http://jongleberry.com"
- },
- {
- "name": "Robert Kieffer",
- "email": "robert@broofa.com",
- "url": "http://github.com/broofa"
- }
- ],
- "deprecated": false,
+ "name": "mime-db",
"description": "Media Type Database",
+ "version": "1.52.0",
+ "contributors": [
+ "Douglas Christopher Wilson ",
+ "Jonathan Ong (http://jongleberry.com)",
+ "Robert Kieffer (http://github.com/broofa)"
+ ],
+ "license": "MIT",
+ "keywords": [
+ "mime",
+ "db",
+ "type",
+ "types",
+ "database",
+ "charset",
+ "charsets"
+ ],
+ "repository": "jshttp/mime-db",
"devDependencies": {
"bluebird": "3.7.2",
"co": "4.6.0",
@@ -63,9 +37,6 @@
"raw-body": "2.5.0",
"stream-to-array": "2.3.0"
},
- "engines": {
- "node": ">= 0.6"
- },
"files": [
"HISTORY.md",
"LICENSE",
@@ -73,21 +44,8 @@
"db.json",
"index.js"
],
- "homepage": "https://github.com/jshttp/mime-db#readme",
- "keywords": [
- "mime",
- "db",
- "type",
- "types",
- "database",
- "charset",
- "charsets"
- ],
- "license": "MIT",
- "name": "mime-db",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/jshttp/mime-db.git"
+ "engines": {
+ "node": ">= 0.6"
},
"scripts": {
"build": "node scripts/build",
@@ -98,6 +56,5 @@
"test-cov": "nyc --reporter=html --reporter=text npm test",
"update": "npm run fetch && npm run build",
"version": "node scripts/version-history.js && git add HISTORY.md"
- },
- "version": "1.52.0"
+ }
}
diff --git a/node_modules/mime-types/package.json b/node_modules/mime-types/package.json
index f188117..bbef696 100644
--- a/node_modules/mime-types/package.json
+++ b/node_modules/mime-types/package.json
@@ -1,53 +1,21 @@
{
- "_from": "mime-types",
- "_id": "mime-types@2.1.35",
- "_inBundle": false,
- "_integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
- "_location": "/mime-types",
- "_phantomChildren": {},
- "_requested": {
- "type": "tag",
- "registry": true,
- "raw": "mime-types",
- "name": "mime-types",
- "escapedName": "mime-types",
- "rawSpec": "",
- "saveSpec": null,
- "fetchSpec": "latest"
- },
- "_requiredBy": [
- "#USER",
- "/"
- ],
- "_resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
- "_shasum": "381a871b62a734450660ae3deee44813f70d959a",
- "_spec": "mime-types",
- "_where": "/home/ubuntu/formidable/a",
- "bugs": {
- "url": "https://github.com/jshttp/mime-types/issues"
- },
- "bundleDependencies": false,
+ "name": "mime-types",
+ "description": "The ultimate javascript content-type utility.",
+ "version": "2.1.35",
"contributors": [
- {
- "name": "Douglas Christopher Wilson",
- "email": "doug@somethingdoug.com"
- },
- {
- "name": "Jeremiah Senkpiel",
- "email": "fishrock123@rocketmail.com",
- "url": "https://searchbeam.jit.su"
- },
- {
- "name": "Jonathan Ong",
- "email": "me@jongleberry.com",
- "url": "http://jongleberry.com"
- }
+ "Douglas Christopher Wilson ",
+ "Jeremiah Senkpiel (https://searchbeam.jit.su)",
+ "Jonathan Ong (http://jongleberry.com)"
],
+ "license": "MIT",
+ "keywords": [
+ "mime",
+ "types"
+ ],
+ "repository": "jshttp/mime-types",
"dependencies": {
"mime-db": "1.52.0"
},
- "deprecated": false,
- "description": "The ultimate javascript content-type utility.",
"devDependencies": {
"eslint": "7.32.0",
"eslint-config-standard": "14.1.1",
@@ -59,30 +27,18 @@
"mocha": "9.2.2",
"nyc": "15.1.0"
},
- "engines": {
- "node": ">= 0.6"
- },
"files": [
"HISTORY.md",
"LICENSE",
"index.js"
],
- "homepage": "https://github.com/jshttp/mime-types#readme",
- "keywords": [
- "mime",
- "types"
- ],
- "license": "MIT",
- "name": "mime-types",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/jshttp/mime-types.git"
+ "engines": {
+ "node": ">= 0.6"
},
"scripts": {
"lint": "eslint .",
"test": "mocha --reporter spec test/test.js",
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
"test-cov": "nyc --reporter=html --reporter=text npm test"
- },
- "version": "2.1.35"
+ }
}
diff --git a/node_modules/tar/CHANGELOG.md b/node_modules/tar/CHANGELOG.md
deleted file mode 100644
index 9373401..0000000
--- a/node_modules/tar/CHANGELOG.md
+++ /dev/null
@@ -1,68 +0,0 @@
-# Changelog
-
-## 6.0
-
-- Drop support for node 6 and 8
-- fix symlinks and hardlinks on windows being packed with `\`-style path
- targets
-
-## 5.0
-
-- Address unpack race conditions using path reservations
-- Change large-numbers errors from TypeError to Error
-- Add `TAR_*` error codes
-- Raise `TAR_BAD_ARCHIVE` warning/error when there are no valid entries
- found in an archive
-- do not treat ignored entries as an invalid archive
-- drop support for node v4
-- unpack: conditionally use a file mapping to write files on Windows
-- Set more portable 'mode' value in portable mode
-- Set `portable` gzip option in portable mode
-
-## 4.4
-
-- Add 'mtime' option to tar creation to force mtime
-- unpack: only reuse file fs entries if nlink = 1
-- unpack: rename before unlinking files on Windows
-- Fix encoding/decoding of base-256 numbers
-- Use `stat` instead of `lstat` when checking CWD
-- Always provide a callback to fs.close()
-
-## 4.3
-
-- Add 'transform' unpack option
-
-## 4.2
-
-- Fail when zlib fails
-
-## 4.1
-
-- Add noMtime flag for tar creation
-
-## 4.0
-
-- unpack: raise error if cwd is missing or not a dir
-- pack: don't drop dots from dotfiles when prefixing
-
-## 3.1
-
-- Support `@file.tar` as an entry argument to copy entries from one tar
- file to another.
-- Add `noPax` option
-- `noResume` option for tar.t
-- win32: convert `>| super.write(chunk))
this.zip.on('end', _ => super.end())
this.zip.on('drain', _ => this[ONDRAIN]())
diff --git a/node_modules/tar/lib/parse.js b/node_modules/tar/lib/parse.js
index 4b85915..94e5304 100644
--- a/node_modules/tar/lib/parse.js
+++ b/node_modules/tar/lib/parse.js
@@ -97,6 +97,16 @@ module.exports = warner(class Parser extends EE {
this.strict = !!opt.strict
this.maxMetaEntrySize = opt.maxMetaEntrySize || maxMetaEntrySize
this.filter = typeof opt.filter === 'function' ? opt.filter : noop
+ // Unlike gzip, brotli doesn't have any magic bytes to identify it
+ // Users need to explicitly tell us they're extracting a brotli file
+ // Or we infer from the file extension
+ const isTBR = (opt.file && (
+ opt.file.endsWith('.tar.br') || opt.file.endsWith('.tbr')))
+ // if it's a tbr file it MIGHT be brotli, but we don't know until
+ // we look at it and verify it's not a valid tar file.
+ this.brotli = !opt.gzip && opt.brotli !== undefined ? opt.brotli
+ : isTBR ? undefined
+ : false
// have to set this so that streams are ok piping into it
this.writable = true
@@ -347,7 +357,9 @@ module.exports = warner(class Parser extends EE {
}
// first write, might be gzipped
- if (this[UNZIP] === null && chunk) {
+ const needSniff = this[UNZIP] === null ||
+ this.brotli === undefined && this[UNZIP] === false
+ if (needSniff && chunk) {
if (this[BUFFER]) {
chunk = Buffer.concat([this[BUFFER], chunk])
this[BUFFER] = null
@@ -356,15 +368,45 @@ module.exports = warner(class Parser extends EE {
this[BUFFER] = chunk
return true
}
+
+ // look for gzip header
for (let i = 0; this[UNZIP] === null && i < gzipHeader.length; i++) {
if (chunk[i] !== gzipHeader[i]) {
this[UNZIP] = false
}
}
- if (this[UNZIP] === null) {
+
+ const maybeBrotli = this.brotli === undefined
+ if (this[UNZIP] === false && maybeBrotli) {
+ // read the first header to see if it's a valid tar file. If so,
+ // we can safely assume that it's not actually brotli, despite the
+ // .tbr or .tar.br file extension.
+ // if we ended before getting a full chunk, yes, def brotli
+ if (chunk.length < 512) {
+ if (this[ENDED]) {
+ this.brotli = true
+ } else {
+ this[BUFFER] = chunk
+ return true
+ }
+ } else {
+ // if it's tar, it's pretty reliably not brotli, chances of
+ // that happening are astronomical.
+ try {
+ new Header(chunk.slice(0, 512))
+ this.brotli = false
+ } catch (_) {
+ this.brotli = true
+ }
+ }
+ }
+
+ if (this[UNZIP] === null || (this[UNZIP] === false && this.brotli)) {
const ended = this[ENDED]
this[ENDED] = false
- this[UNZIP] = new zlib.Unzip()
+ this[UNZIP] = this[UNZIP] === null
+ ? new zlib.Unzip()
+ : new zlib.BrotliDecompress()
this[UNZIP].on('data', chunk => this[CONSUMECHUNK](chunk))
this[UNZIP].on('error', er => this.abort(er))
this[UNZIP].on('end', _ => {
@@ -502,6 +544,7 @@ module.exports = warner(class Parser extends EE {
this[UNZIP].end(chunk)
} else {
this[ENDED] = true
+ if (this.brotli === undefined) chunk = chunk || Buffer.alloc(0)
this.write(chunk)
}
}
diff --git a/node_modules/tar/lib/replace.js b/node_modules/tar/lib/replace.js
index c6e619b..8db6800 100644
--- a/node_modules/tar/lib/replace.js
+++ b/node_modules/tar/lib/replace.js
@@ -23,7 +23,7 @@ module.exports = (opt_, files, cb) => {
throw new TypeError('file is required')
}
- if (opt.gzip) {
+ if (opt.gzip || opt.brotli || opt.file.endsWith('.br') || opt.file.endsWith('.tbr')) {
throw new TypeError('cannot append to compressed archives')
}
diff --git a/node_modules/tar/lib/update.js b/node_modules/tar/lib/update.js
index ded977d..4d32854 100644
--- a/node_modules/tar/lib/update.js
+++ b/node_modules/tar/lib/update.js
@@ -13,7 +13,7 @@ module.exports = (opt_, files, cb) => {
throw new TypeError('file is required')
}
- if (opt.gzip) {
+ if (opt.gzip || opt.brotli || opt.file.endsWith('.br') || opt.file.endsWith('.tbr')) {
throw new TypeError('cannot append to compressed archives')
}
diff --git a/node_modules/tar/package.json b/node_modules/tar/package.json
index d8dc955..46d91ee 100644
--- a/node_modules/tar/package.json
+++ b/node_modules/tar/package.json
@@ -1,35 +1,17 @@
{
- "_from": "tar",
- "_id": "tar@6.1.15",
- "_inBundle": false,
- "_integrity": "sha512-/zKt9UyngnxIT/EAGYuxaMYgOIJiP81ab9ZfkILq4oNLPFX50qyYmu7jRj9qeXoxmJHjGlbH0+cm2uy1WCs10A==",
- "_location": "/tar",
- "_phantomChildren": {},
- "_requested": {
- "type": "tag",
- "registry": true,
- "raw": "tar",
- "name": "tar",
- "escapedName": "tar",
- "rawSpec": "",
- "saveSpec": null,
- "fetchSpec": "latest"
+ "author": "GitHub Inc.",
+ "name": "tar",
+ "description": "tar for node",
+ "version": "6.2.0",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/isaacs/node-tar.git"
},
- "_requiredBy": [
- "#USER",
- "/"
- ],
- "_resolved": "https://registry.npmjs.org/tar/-/tar-6.1.15.tgz",
- "_shasum": "c9738b0b98845a3b344d334b8fa3041aaba53a69",
- "_spec": "tar",
- "_where": "/home/ubuntu/fix",
- "author": {
- "name": "GitHub Inc."
+ "scripts": {
+ "genparse": "node scripts/generate-parse-fixtures.js",
+ "snap": "tap",
+ "test": "tap"
},
- "bugs": {
- "url": "https://github.com/isaacs/node-tar/issues"
- },
- "bundleDependencies": false,
"dependencies": {
"chownr": "^2.0.0",
"fs-minipass": "^2.0.0",
@@ -38,8 +20,6 @@
"mkdirp": "^1.0.3",
"yallist": "^4.0.0"
},
- "deprecated": false,
- "description": "tar for node",
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.11.0",
@@ -51,6 +31,7 @@
"rimraf": "^3.0.2",
"tap": "^16.0.1"
},
+ "license": "ISC",
"engines": {
"node": ">=10"
},
@@ -59,23 +40,6 @@
"lib/",
"index.js"
],
- "homepage": "https://github.com/isaacs/node-tar#readme",
- "license": "ISC",
- "name": "tar",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/isaacs/node-tar.git"
- },
- "scripts": {
- "genparse": "node scripts/generate-parse-fixtures.js",
- "lint": "eslint \"**/*.js\"",
- "lintfix": "npm run lint -- --fix",
- "postlint": "template-oss-check",
- "posttest": "npm run lint",
- "snap": "tap",
- "template-oss-apply": "template-oss-apply --force",
- "test": "tap"
- },
"tap": {
"coverage-map": "map.js",
"timeout": 0,
@@ -102,6 +66,5 @@
"16.x",
"18.x"
]
- },
- "version": "6.1.15"
+ }
}
diff --git a/svr.js b/svr.js
index 52ec115..d5db0e4 100644
--- a/svr.js
+++ b/svr.js
@@ -69,7 +69,7 @@ function deleteFolderRecursive(path) {
}
var os = require("os");
-var version = "3.14.3";
+var version = "3.14.4";
var singlethreaded = false;
if (process.versions) process.versions.svrjs = version; // Inject SVR.JS into process.versions
@@ -873,8 +873,8 @@ function generateErrorStack(errorObject) {
// If the error stack starts with the error name, return the original stack (it is V8-style then).
if (errorStack.some(function (errorStackLine) {
- return (errorStackLine.indexOf(errorObject.name) == 0);
- })) {
+ return (errorStackLine.indexOf(errorObject.name) == 0);
+ })) {
return errorObject.stack;
}
@@ -1176,6 +1176,8 @@ var disableTrailingSlashRedirects = false;
var environmentVariables = {};
var wwwrootPostfixesVHost = [];
var wwwrootPostfixPrefixesVHost = [];
+var allowDoubleSlashes = false;
+var allowPostfixDoubleSlashes = false;
// Get properties from config.json
if (configJSON.blacklist != undefined) rawBlackList = configJSON.blacklist;
@@ -1231,6 +1233,8 @@ if (configJSON.disableTrailingSlashRedirects != undefined) disableTrailingSlashR
if (configJSON.environmentVariables != undefined) environmentVariables = configJSON.environmentVariables;
if (configJSON.wwwrootPostfixesVHost != undefined) wwwrootPostfixesVHost = configJSON.wwwrootPostfixesVHost;
if (configJSON.wwwrootPostfixPrefixesVHost != undefined) wwwrootPostfixPrefixesVHost = configJSON.wwwrootPostfixPrefixesVHost;
+if (configJSON.allowDoubleSlashes != undefined) allowDoubleSlashes = configJSON.allowDoubleSlashes;
+if (configJSON.allowPostfixDoubleSlashes != undefined) allowPostfixDoubleSlashes = configJSON.allowPostfixDoubleSlashes;
var wwwrootError = null;
try {
@@ -1288,13 +1292,12 @@ if (vnum === undefined) vnum = 0;
if (process.isBun) vnum = 64;
// SVR.JS path sanitizer function
-function sanitizeURL(resource) {
- if (resource == "*") return "*";
- if (resource == "") return "";
+function sanitizeURL(resource, allowDoubleSlashes) {
+ if (resource == "*" || resource == "") return resource;
// Remove null characters
- resource = resource.replace(/%00/ig, "").replace(/\0/g, "");
+ resource = resource.replace(/%00|\0/g, "");
// Check if URL is malformed (e.g. %c0%af or %u002f or simply %as)
- if (resource.match(/%(?:c[01]|f[ef]|(?![0-9a-f]{2}).{2}|.{0,1}$)/gi)) throw new URIError("URI malformed");
+ if (resource.match(/%(?:c[01]|f[ef]|(?![0-9a-f]{2}).{2}|.{0,1}$)/i)) throw new URIError("URI malformed");
// Decode URL-encoded characters while preserving certain characters
resource = resource.replace(/%([0-9a-f]{2})/gi, function (match, hex) {
var decodedChar = String.fromCharCode(parseInt(hex, 16));
@@ -1308,14 +1311,14 @@ function sanitizeURL(resource) {
var sanitizedResource = resource;
// Ensure the resource starts with a slash
if (resource[0] != "/") sanitizedResource = "/" + sanitizedResource;
- // Convert backslashes to slashes and remove duplicate slashes
- sanitizedResource = sanitizedResource.replace(/\\/g, "/").replace(/\/+/g, "/");
+ // Convert backslashes to slashes and handle duplicate slashes
+ sanitizedResource = sanitizedResource.replace(/\\/g, "/").replace(allowDoubleSlashes ? /\/{3,}/g : /\/+/g, "/");
// Handle relative navigation (e.g., "/./", "/../", "../", "./"), also remove trailing dots in paths
- sanitizedResource = sanitizedResource.replace(/\/\.(?:\.{2,})?(?=($|\/))/g, "$1").replace(/([^.\/])\.+(?=($|\/))/g, "$1$2").replace(/\/+/g, "/");
- while (sanitizedResource.match(/\/(?!\.\.\/)[^\/]+\/\.\.(?=(\/|$))/g)) {
- sanitizedResource = sanitizedResource.replace(/\/(?!\.\.\/)[^\/]+\/\.\.(?=(\/|$))/g, "$1").replace(/\/+/g, "/");
+ sanitizedResource = sanitizedResource.replace(/\/\.(?:\.{2,})?(?=\/|$)/g, "").replace(/([^.\/])\.+(?=\/|$)/g, "$1");
+ while (sanitizedResource.match(/\/(?!\.\.\/)[^\/]+\/\.\.(?=\/|$)/)) {
+ sanitizedResource = sanitizedResource.replace(/\/(?!\.\.\/)[^\/]+\/\.\.(?=\/|$)/g, "");
}
- sanitizedResource = sanitizedResource.replace(/\/\.\.(?=(\/|$))/g, "$1").replace(/\/+/g, "/");
+ sanitizedResource = sanitizedResource.replace(/\/\.\.(?=\/|$)/g, "");
if (sanitizedResource.length == 0) return "/";
else return sanitizedResource;
}
@@ -3328,17 +3331,19 @@ if (!cluster.isPrimary) {
// Function to parse a URL string into a URL object
function parseURL(uri) {
+ // Prepare the path (remove multiple slashes)
+ var preparedURI = uri.replace(/^\/{2,}/,"/");
// Check if the URL API is available (Node.js version >= 10)
if (typeof URL !== "undefined" && url.Url) {
try {
// Create a new URL object using the provided URI and base URL
- var uobject = new URL(uri.replace(/^\/{2,}/,"/"), "http" + (req.socket.encrypted ? "s" : "") + "://" + (req.headers.host ? req.headers.host : (domain ? domain : "unknown.invalid")));
+ var uobject = new URL(preparedURI, "http" + (req.socket.encrypted ? "s" : "") + "://" + (req.headers.host ? req.headers.host : (domain ? domain : "unknown.invalid")));
// Create a new URL object (similar to deprecated url.Url)
var nuobject = new url.Url();
// Set properties of the new URL object from the provided URL
- if (uri.indexOf("/") != -1) nuobject.slashes = true;
+ if (preparedURI.indexOf("/") != -1) nuobject.slashes = true;
if (uobject.protocol != "") nuobject.protocol = uobject.protocol;
if (uobject.username != "" && uobject.password != "") nuobject.auth = uobject.username + ":" + uobject.password;
if (uobject.host != "") nuobject.host = uobject.host;
@@ -3350,7 +3355,7 @@ if (!cluster.isPrimary) {
if (uobject.href != "") nuobject.href = uobject.href;
// Adjust the pathname and href properties if the URI doesn't start with "/"
- if (uri.indexOf("/") != 0) {
+ if (preparedURI.indexOf("/") != 0) {
if (nuobject.pathname) {
nuobject.pathname = nuobject.pathname.substr(1);
nuobject.href = nuobject.pathname + (nuobject.search ? nuobject.search : "");
@@ -3372,11 +3377,11 @@ if (!cluster.isPrimary) {
return nuobject;
} catch (err) {
// If there was an error using the URL API, fall back to deprecated url.parse
- return url.parse(uri, true);
+ return url.parse(preparedURI, true);
}
} else {
// If the URL API is not available, fall back to deprecated url.parse
- return url.parse(uri, true);
+ return url.parse(preparedURI, true);
}
}
@@ -3618,23 +3623,23 @@ if (!cluster.isPrimary) {
var customDirListingHeader = fs.existsSync(("." + decodeURIComponent(href) + "/.dirhead").replace(/\/+/g, "/")) ?
fs.readFileSync(("." + decodeURIComponent(href) + "/.dirhead").replace(/\/+/g, "/")).toString() :
(fs.existsSync(("." + decodeURIComponent(href) + "/HEAD.html").replace(/\/+/g, "/")) && (os.platform != "win32" || href != "/")) ?
- fs.readFileSync(("." + decodeURIComponent(href) + "/HEAD.html").replace(/\/+/g, "/")).toString() :
- "";
+ fs.readFileSync(("." + decodeURIComponent(href) + "/HEAD.html").replace(/\/+/g, "/")).toString() :
+ "";
var customDirListingFooter = fs.existsSync(("." + decodeURIComponent(href) + "/.dirfoot").replace(/\/+/g, "/")) ?
fs.readFileSync(("." + decodeURIComponent(href) + "/.dirfoot").replace(/\/+/g, "/")).toString() :
(fs.existsSync(("." + decodeURIComponent(href) + "/FOOT.html").replace(/\/+/g, "/")) && (os.platform != "win32" || href != "/")) ?
- fs.readFileSync(("." + decodeURIComponent(href) + "/FOOT.html").replace(/\/+/g, "/")).toString() :
- "";
+ fs.readFileSync(("." + decodeURIComponent(href) + "/FOOT.html").replace(/\/+/g, "/")).toString() :
+ "";
// Check if custom header has HTML tag
var headerHasHTMLTag = customDirListingHeader.replace(/|$)/g, "").match(/])*(?:>|$)/i);
// Generate HTML head and footer based on configuration and custom content
var htmlHead = (!configJSON.enableDirectoryListingWithDefaultHead || head == "" ?
- (!headerHasHTMLTag ?
- "Directory: " + decodeURIComponent(origHref).replace(/&/g, "&").replace(//g, ">") + "" :
- customDirListingHeader.replace(//i, "Directory: " + decodeURIComponent(origHref).replace(/&/g, "&").replace(//g, ">") + "")) :
- head.replace(//i, "Directory: " + decodeURIComponent(origHref).replace(/&/g, "&").replace(//g, ">") + "")) +
+ (!headerHasHTMLTag ?
+ "Directory: " + decodeURIComponent(origHref).replace(/&/g, "&").replace(//g, ">") + "" :
+ customDirListingHeader.replace(//i, "Directory: " + decodeURIComponent(origHref).replace(/&/g, "&").replace(//g, ">") + "")) :
+ head.replace(//i, "Directory: " + decodeURIComponent(origHref).replace(/&/g, "&").replace(//g, ">") + "")) +
(!headerHasHTMLTag ? customDirListingHeader : "") +
"Directory: " + decodeURIComponent(origHref).replace(/&/g, "&").replace(//g, ">") + "
| Filename | Size | Date |
" + (checkPathLevel(decodeURIComponent(origHref)) < 1 ? "" : " | Return | | |
");
@@ -3770,7 +3775,7 @@ if (!cluster.isPrimary) {
} else if (estats.isSocket()) {
entry = entry.replace("[img]", "/.dirimages/socket.png").replace("[alt]", "[SCK]");
}
- } else if ((/README/ig).test(ename) || (/LICEN[SC]E/ig).test(ename)) {
+ } else if (ename.match(/README|LICEN[SC]E/i)) {
entry = entry.replace("[img]", "/.dirimages/important.png").replace("[alt]", "[IMP]");
} else if (checkEXT(ename, ".html") || checkEXT(ename, ".htm") || checkEXT(ename, ".xml") || checkEXT(ename, ".xhtml") || checkEXT(ename, ".shtml")) {
entry = entry.replace("[img]", "/.dirimages/html.png").replace("[alt]", (checkEXT(ename, ".xml") ? "[XML]" : "[HTM]"));
@@ -4154,7 +4159,7 @@ if (!cluster.isPrimary) {
}
// Sanitize URL
- var sanitizedHref = sanitizeURL(href);
+ var sanitizedHref = sanitizeURL(href, allowDoubleSlashes);
var preparedReqUrl = uobject.pathname + (uobject.search ? uobject.search : "") + (uobject.hash ? uobject.hash : "");
// Check if URL is "dirty"
@@ -4214,67 +4219,22 @@ if (!cluster.isPrimary) {
return;
}
- var urlp = parseURL("http://" + hostx);
- try {
- if (urlp.path.indexOf("//") == 0) {
- urlp = parseURL("http:" + url.path);
- }
- } catch (err) {
- // URL parse error...
- }
+ var isPublicServer = !(req.socket.realRemoteAddress ? req.socket.realRemoteAddress : req.socket.remoteAddress).match(/^(?:localhost$|::1$|f[c-d][0-9a-f]{2}:|(?:::ffff:)?(?:(?:127|10)\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|192\.168\.[0-9]{1,3}\.[0-9]{1,3}|172\.(?:1[6-9]|2[0-9]|3[0-1])\.[0-9]{1,3}\.[0-9]{1,3})$)/i);
- if (urlp.host == "localhost" || urlp.host == "localhost:" + port.toString() || urlp.host == "127.0.0.1" || urlp.host == "127.0.0.1:" + port.toString() || urlp.host == "::1" || urlp.host == "::1:" + port.toString()) {
- urlp.protocol = "https:";
- if (sport == 443) {
- urlp.host = urlp.hostname;
- } else {
- urlp.host = urlp.hostname + ":" + sport.toString();
- urlp.port = sport.toString();
- }
- } else if (urlp.host == (listenAddress ? listenAddress : host) || urlp.host == (listenAddress ? listenAddress : host) + ":" + port.toString()) {
- urlp.protocol = "https:";
- if (sport == 443) {
- urlp.host = urlp.hostname;
- } else {
- urlp.host = urlp.hostname + ":" + sport.toString();
- urlp.port = sport.toString();
- }
- } else if (urlp.host == pubip || urlp.host == pubip + ":" + pubport.toString()) {
- urlp.protocol = "https:";
- if (spubport == 443) {
- urlp.host = urlp.hostname;
- } else {
- urlp.host = urlp.hostname + ":" + spubport.toString();
- urlp.port = spubport.toString();
- }
- } else if (urlp.hostname == domain || urlp.hostname.indexOf(domain) != -1) {
- urlp.protocol = "https:";
- if (spubport == 443) {
- urlp.host = urlp.hostname;
- } else {
- urlp.host = urlp.hostname + ":" + spubport.toString();
- urlp.port = spubport.toString();
- }
+ var destinationPort = 0;
+
+ var parsedHostx = hostx.match(/(\[[^\]]*\]|[^:]*)(?::([0-9]+))?/);
+ var hostname = parsedHostx[1];
+ var hostPort = parsedHostx[2] ? parseInt(parsedHostx[2]) : 80;
+ if (isNaN(hostPort)) hostPort = 80;
+
+ if (hostPort == port || (port == pubport && !isPublicServer)) {
+ destinationPort = sport;
} else {
- urlp.protocol = "https:";
- }
- urlp.path = null;
- urlp.pathname = null;
- var lloc = url.format(urlp);
- var requestURL = req.url;
- try {
- if (requestURL.split("/")[1].indexOf(".onion") != -1) {
- requestURL = requestURL.split("/");
- requestURL.shift();
- requestURL.shift();
- requestURL.unshift("");
- requestURL = requestURL.join("/");
- }
- } catch (err) {
- // Leave URL as it is...
+ destinationPort = spubport;
}
- redirect(lloc + requestURL);
+ redirect("https://" + hostname + (destinationPort == 443 ? "" : (":" + destinationPort)) + req.url);
return;
}
@@ -4313,7 +4273,13 @@ if (!cluster.isPrimary) {
doCallback = false;
break;
}
+ var tempRewrittenURL = rewrittenURL;
+ if (!mapEntry.allowDoubleSlashes) {
+ address = address.replace(/\/+/g,"/");
+ tempRewrittenURL = address;
+ }
if (matchHostname(mapEntry.host) && ipMatch(mapEntry.ip, req.socket ? req.socket.localAddress : undefined) && address.match(createRegex(mapEntry.definingRegex)) && !(mapEntry.isNotDirectory && _fileState == 2) && !(mapEntry.isNotFile && _fileState == 1)) {
+ rewrittenURL = tempRewrittenURL;
try {
mapEntry.replacements.forEach(function (replacement) {
rewrittenURL = rewrittenURL.replace(createRegex(replacement.regex), replacement.replacement);
@@ -4321,7 +4287,7 @@ if (!cluster.isPrimary) {
if (mapEntry.append) rewrittenURL += mapEntry.append;
} catch (err) {
doCallback = false;
- callback(err, address);
+ callback(err, null);
}
break;
}
@@ -4363,10 +4329,11 @@ if (!cluster.isPrimary) {
// Add web root postfixes
if (!isProxy) {
- var urlWithPostfix = req.url;
+ var preparedReqUrl3 = (allowPostfixDoubleSlashes ? (href.replace(/\/+/,"/") + (uobject.search ? uobject.search : "") + (uobject.hash ? uobject.hash : "")) : req.url);
+ var urlWithPostfix = preparedReqUrl3;
var postfixPrefix = "";
wwwrootPostfixPrefixesVHost.every(function (currentPostfixPrefix) {
- if (req.url.indexOf(currentPostfixPrefix) == 0) {
+ if (preparedReqUrl3.indexOf(currentPostfixPrefix) == 0) {
if (currentPostfixPrefix.match(/\/+$/)) postfixPrefix = currentPostfixPrefix.replace(/\/+$/, "");
else if (urlWithPostfix.length == currentPostfixPrefix.length || urlWithPostfix[currentPostfixPrefix.length] == "?" || urlWithPostfix[currentPostfixPrefix.length] == "/" || urlWithPostfix[currentPostfixPrefix.length] == "#") postfixPrefix = currentPostfixPrefix;
else return true;
@@ -4377,14 +4344,14 @@ if (!cluster.isPrimary) {
}
});
wwwrootPostfixesVHost.every(function (postfixEntry) {
- if (matchHostname(postfixEntry.host) && ipMatch(postfixEntry.ip, req.socket ? req.socket.localAddress : undefined) && !(postfixEntry.skipRegex && req.url.match(createRegex(postfixEntry.skipRegex)))) {
+ if (matchHostname(postfixEntry.host) && ipMatch(postfixEntry.ip, req.socket ? req.socket.localAddress : undefined) && !(postfixEntry.skipRegex && preparedReqUrl3.match(createRegex(postfixEntry.skipRegex)))) {
urlWithPostfix = postfixPrefix + "/" + postfixEntry.postfix + urlWithPostfix;
return false;
} else {
return true;
}
});
- if (urlWithPostfix != req.url) {
+ if (urlWithPostfix != preparedReqUrl3) {
serverconsole.resmessage("Added web root postfix: " + req.url + " => " + urlWithPostfix);
req.url = urlWithPostfix;
uobject = parseURL(req.url);
@@ -4402,7 +4369,7 @@ if (!cluster.isPrimary) {
return;
}
- var sHref = sanitizeURL(href);
+ var sHref = sanitizeURL(href, allowDoubleSlashes);
var preparedReqUrl2 = uobject.pathname + (uobject.search ? uobject.search : "") + (uobject.hash ? uobject.hash : "");
if (req.url != preparedReqUrl2 || sHref != href.replace(/\/\.(?=\/|$)/g, "/").replace(/\/+/g, "/")) {
@@ -4463,7 +4430,7 @@ if (!cluster.isPrimary) {
return;
}
- var sHref = sanitizeURL(href);
+ var sHref = sanitizeURL(href, allowDoubleSlashes);
var preparedReqUrl2 = uobject.pathname + (uobject.search ? uobject.search : "") + (uobject.hash ? uobject.hash : "");
if (req.url != preparedReqUrl2 || sHref != href.replace(/\/\.(?=\/|$)/g, "/").replace(/\/+/g, "/")) {
@@ -4510,24 +4477,27 @@ if (!cluster.isPrimary) {
});
}
+ // Prepare the path (remove multiple slashes)
+ var decodedHrefWithoutDuplicateSlashes = decodedHref.replace(/\/+/g,"/");
+
// Check if path is forbidden
- if ((isForbiddenPath(decodedHref, "config") || isForbiddenPath(decodedHref, "certificates")) && !isProxy) {
+ if ((isForbiddenPath(decodedHrefWithoutDuplicateSlashes, "config") || isForbiddenPath(decodedHrefWithoutDuplicateSlashes, "certificates")) && !isProxy) {
callServerError(403);
serverconsole.errmessage("Access to configuration file/certificates is denied.");
return;
- } else if (isIndexOfForbiddenPath(decodedHref, "temp") && !isProxy) {
+ } else if (isIndexOfForbiddenPath(decodedHrefWithoutDuplicateSlashes, "temp") && !isProxy) {
callServerError(403);
serverconsole.errmessage("Access to temporary folder is denied.");
return;
- } else if (isIndexOfForbiddenPath(decodedHref, "log") && !isProxy && (configJSON.enableLogging || configJSON.enableLogging == undefined) && !configJSON.enableRemoteLogBrowsing) {
+ } else if (isIndexOfForbiddenPath(decodedHrefWithoutDuplicateSlashes, "log") && !isProxy && (configJSON.enableLogging || configJSON.enableLogging == undefined) && !configJSON.enableRemoteLogBrowsing) {
callServerError(403);
serverconsole.errmessage("Access to log files is denied.");
return;
- } else if (isForbiddenPath(decodedHref, "svrjs") && !isProxy && !exposeServerVersion) {
+ } else if (isForbiddenPath(decodedHrefWithoutDuplicateSlashes, "svrjs") && !isProxy && !exposeServerVersion) {
callServerError(403);
serverconsole.errmessage("Access to SVR.JS script is denied.");
return;
- } else if ((isForbiddenPath(decodedHref, "svrjs") || isForbiddenPath(decodedHref, "serverSideScripts") || isIndexOfForbiddenPath(decodedHref, "serverSideScriptDirectories")) && !isProxy && (configJSON.disableServerSideScriptExpose || configJSON.disableServerSideScriptExpose === undefined)) {
+ } else if ((isForbiddenPath(decodedHrefWithoutDuplicateSlashes, "svrjs") || isForbiddenPath(decodedHrefWithoutDuplicateSlashes, "serverSideScripts") || isIndexOfForbiddenPath(decodedHrefWithoutDuplicateSlashes, "serverSideScriptDirectories")) && !isProxy && (configJSON.disableServerSideScriptExpose || configJSON.disableServerSideScriptExpose === undefined)) {
callServerError(403);
serverconsole.errmessage("Access to sources is denied.");
return;
@@ -4541,14 +4511,15 @@ if (!cluster.isPrimary) {
for (var i = 0; i < nonStandardCodes.length; i++) {
if (matchHostname(nonStandardCodes[i].host) && ipMatch(nonStandardCodes[i].ip, req.socket ? req.socket.localAddress : undefined)) {
var isMatch = false;
+ var hrefWithoutDuplicateSlashes = href.replace(/\/+/g,"/");
if (nonStandardCodes[i].regex) {
// Regex match
var createdRegex = createRegex(nonStandardCodes[i].regex, true);
- isMatch = req.url.match(createdRegex) || href.match(createdRegex);
+ isMatch = req.url.match(createdRegex) || hrefWithoutDuplicateSlashes.match(createdRegex);
regexI[i] = createdRegex;
} else {
// Non-regex match
- isMatch = nonStandardCodes[i].url == href || (os.platform() == "win32" && nonStandardCodes[i].url.toLowerCase() == href.toLowerCase());
+ isMatch = nonStandardCodes[i].url == hrefWithoutDuplicateSlashes || (os.platform() == "win32" && nonStandardCodes[i].url.toLowerCase() == hrefWithoutDuplicateSlashes.toLowerCase());
}
if (isMatch) {
if (nonStandardCodes[i].scode == 401) {
@@ -4577,6 +4548,10 @@ if (!cluster.isPrimary) {
var location = "";
if (regexI[nonscodeIndex]) {
location = req.url.replace(regexI[nonscodeIndex], nonscode.location);
+ if(location == req.url) {
+ // Fallback replacement
+ location = hrefWithoutDuplicateSlashes.replace(regexI[nonscodeIndex], nonscode.location);
+ }
} else if (req.url.split("?")[1] == undefined || req.url.split("?")[1] == null || req.url.split("?")[1] == "" || req.url.split("?")[1] == " ") {
location = nonscode.location;
} else {
@@ -5075,11 +5050,11 @@ function start(init) {
if (process.isBun) {
serverconsole.locwarnmessage("Bun support is experimental. Some features of SVR.JS, SVR.JS mods and SVR.JS server-side JavaScript may not work as expected.");
if (users.some(function (entry) {
- return entry.pbkdf2;
- })) serverconsole.locwarnmessage("PBKDF2 password hashing function in Bun blocks the event loop, which may result in denial of service.");
+ return entry.pbkdf2;
+ })) serverconsole.locwarnmessage("PBKDF2 password hashing function in Bun blocks the event loop, which may result in denial of service.");
if (users.some(function (entry) {
- return entry.scrypt;
- })) serverconsole.locwarnmessage("scrypt password hashing function in Bun blocks the event loop, which may result in denial of service.");
+ return entry.scrypt;
+ })) serverconsole.locwarnmessage("scrypt password hashing function in Bun blocks the event loop, which may result in denial of service.");
}
if (cluster.isPrimary === undefined) serverconsole.locwarnmessage("You're running SVR.JS on single thread. Reliability may suffer, as the server is stopped after crash.");
if (crypto.__disabled__ !== undefined) serverconsole.locwarnmessage("Your Node.JS version doesn't have crypto support! The 'crypto' module is essential for providing cryptographic functionality in Node.JS. Without crypto support, certain security features may be unavailable, and some functionality may not work as expected. It's recommended to use a Node.JS version that includes crypto support to ensure the security and proper functioning of your server.");
@@ -5829,6 +5804,7 @@ function saveConfig() {
if (configJSONobj.exposeModsInErrorPages === undefined) configJSONobj.exposeModsInErrorPages = true;
if (configJSONobj.disableTrailingSlashRedirects === undefined) configJSONobj.disableTrailingSlashRedirects = false;
if (configJSONobj.environmentVariables === undefined) configJSONobj.environmentVariables = {};
+ if (configJSONobj.allowDoubleSlashes === undefined) configJSONobj.allowDoubleSlashes = false;
var configString = JSON.stringify(configJSONobj, null, 2) + "\n";
fs.writeFileSync(__dirname + "/config.json", configString);
diff --git a/tests.html b/tests.html
index 2c44581..a6a864c 100644
--- a/tests.html
+++ b/tests.html
@@ -1,7 +1,7 @@
- SVR.JS 3.14.3 Tests
+ SVR.JS 3.14.4 Tests
- SVR.JS 3.14.3 Tests
+ SVR.JS 3.14.4 Tests
Directory (without trailing slash)
Directory (with query)