Arlolra has uploaded a new change for review.
https://gerrit.wikimedia.org/r/93001
Change subject: Parse multipart/form-data with busboy
......................................................................
Parse multipart/form-data with busboy
Gets rid of deprecation warnings.
Change-Id: I58804bde5e20898b7ae2d98256e1871098bb0267
---
M js/api/ParserService.js
1 file changed, 21 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid
refs/changes/01/93001/1
diff --git a/js/api/ParserService.js b/js/api/ParserService.js
index f52d728..5318f23 100644
--- a/js/api/ParserService.js
+++ b/js/api/ParserService.js
@@ -19,6 +19,7 @@
// global includes
var express = require('express'),
+ busboy = require('connect-busboy'),
domino = require( 'domino' ),
jsDiff = require('diff'),
childProc = require('child_process'),
@@ -104,7 +105,7 @@
* @param {string} content The content we should put in the textarea
*/
var textarea = function ( res, action, name, content ) {
- res.write('<form method=POST action="' + action + '"><textarea name="'
+ name + '" cols=90 rows=9>');
+ res.write('<form method=POST action="' + action + '"
enctype="multipart/form-data"><textarea name="' + name + '" cols=90 rows=9>');
res.write( ( content && htmlSpecialChars( content) ) || '' );
res.write('</textarea><br><input type="submit"></form>');
};
@@ -351,15 +352,29 @@
// favicon
app.use(express.favicon(path.join(__dirname, "favicon.ico")));
-//
+
// Support gzip / deflate transfer-encoding
app.use(express.compress());
// Increase the form field size limit from the 2M default.
-// This throws deprecation warnings from connect. Need to investigate
-// alternatives- maybe ditch connect completely and go for plain node http
-// instead?
-app.use(express.bodyParser({maxFieldsSize: 15 * 1024 * 1024}));
+app.use(express.json({ limit: "15mb" }));
+app.use(express.urlencoded({ limit: "15mb" }));
+app.use(busboy({
+ immediate: true,
+ limits: { fieldSize: 15 * 1024 * 1024 }
+}));
+app.use(function (req, res, next) {
+ if ( !req.busboy ) {
+ return next();
+ }
+ req.body = req.body || {};
+ req.busboy.on('field', function ( field, val ) {
+ req.body[field] = val;
+ });
+ req.busboy.on('end', function () {
+ next();
+ });
+});
app.get('/', function(req, res){
res.write('<html><body>\n');
--
To view, visit https://gerrit.wikimedia.org/r/93001
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I58804bde5e20898b7ae2d98256e1871098bb0267
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits