jenkins-bot has submitted this change and it was merged.
Change subject: Parse multipart/form-data with busboy
......................................................................
Parse multipart/form-data with busboy
Gets rid of deprecation warnings.
Bug: 56436
Change-Id: I58804bde5e20898b7ae2d98256e1871098bb0267
---
M js/api/ParserService.js
M js/package.json
2 files changed, 24 insertions(+), 8 deletions(-)
Approvals:
GWicke: Looks good to me, approved
jenkins-bot: Verified
diff --git a/js/api/ParserService.js b/js/api/ParserService.js
index f52d728..e92a1fe 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}));
+// Support multipart/form-data parsing
+app.use(busboy({
+ immediate: true,
+ // Increase the form field size limit from the 1M default.
+ 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');
diff --git a/js/package.json b/js/package.json
index d0ef572..a0b3fce 100644
--- a/js/package.json
+++ b/js/package.json
@@ -18,7 +18,8 @@
"express": ">=3.0.0",
"html5-entities": "~0.5.0",
"html5": "0.3.15",
- "es6-shim":
"git+https://github.com/paulmillr/es6-shim#7dc668687c3a89ed9e7b6d6c6369f0ba8ebf8731"
+ "es6-shim":
"git+https://github.com/paulmillr/es6-shim#7dc668687c3a89ed9e7b6d6c6369f0ba8ebf8731",
+ "connect-busboy": "0.0.1"
},
"devDependencies": {
"colors": "0.x.x",
--
To view, visit https://gerrit.wikimedia.org/r/93001
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I58804bde5e20898b7ae2d98256e1871098bb0267
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits