Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Keep patch-package patches byte-stable across platforms (no CRLF conversion)
patches/**/*.patch -text
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Changelog

Maintained fork of screenshot-basic.

## Unreleased

### Fixed
- Node logged a DEP0005 deprecation warning on every screenshot upload. The
bundled `formidable@1.2.2` (pulled in by `koa-body@4`) still called the old
`Buffer()` constructor in `MultipartParser.initWithBoundary` and the base64
part decoder.

formidable 1.x never moved to the safe Buffer APIs, and the versions that did
(formidable 2/3) need koa-body 5/6 and webpack 5, which FiveM's bundled
webpack 4 cannot compile. So the fix stays on formidable 1.x and patches the
four calls through `patch-package`, reapplied on `postinstall`:
- `new Buffer(n)` to `Buffer.alloc(n)` (boundary and lookbehind)
- `new Buffer(str, 'base64')` to `Buffer.from(str, 'base64')` (two base64 decodes)

No runtime change: the boundary buffer is fully written before use, and the
base64 calls take strings, never the uninitialized-number form.

Author: MrWhitee
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "patch-package"
},
"author": "",
"license": "MIT",
"devDependencies": {
"patch-package": "^8.0.0",
"postinstall-postinstall": "^2.1.0"
},
"dependencies": {
"@citizenfx/client": "^1.0.3404-1",
"@citizenfx/http-wrapper": "^0.2.2",
Expand Down
36 changes: 36 additions & 0 deletions patches/formidable+1.2.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/node_modules/formidable/lib/incoming_form.js b/node_modules/formidable/lib/incoming_form.js
index dbd920b..4e8c962 100644
--- a/node_modules/formidable/lib/incoming_form.js
+++ b/node_modules/formidable/lib/incoming_form.js
@@ -403,12 +403,12 @@ IncomingForm.prototype._initMultipart = function(boundary) {
can be divided vy 3.
*/
var offset = parseInt(part.transferBuffer.length / 4, 10) * 4;
- part.emit('data', new Buffer(part.transferBuffer.substring(0, offset), 'base64'));
+ part.emit('data', Buffer.from(part.transferBuffer.substring(0, offset), 'base64'));
part.transferBuffer = part.transferBuffer.substring(offset);
};

parser.onPartEnd = function() {
- part.emit('data', new Buffer(part.transferBuffer, 'base64'));
+ part.emit('data', Buffer.from(part.transferBuffer, 'base64'));
part.emit('end');
};
break;
diff --git a/node_modules/formidable/lib/multipart_parser.js b/node_modules/formidable/lib/multipart_parser.js
index 36de2b0..071d205 100644
--- a/node_modules/formidable/lib/multipart_parser.js
+++ b/node_modules/formidable/lib/multipart_parser.js
@@ -57,10 +57,10 @@ MultipartParser.stateToString = function(stateNumber) {
};

MultipartParser.prototype.initWithBoundary = function(str) {
- this.boundary = new Buffer(str.length+4);
+ this.boundary = Buffer.alloc(str.length+4);
this.boundary.write('\r\n--', 0);
this.boundary.write(str, 4);
- this.lookbehind = new Buffer(this.boundary.length+8);
+ this.lookbehind = Buffer.alloc(this.boundary.length+8);
this.state = S.START;

this.boundaryChars = {};