Skip to content

Commit d15672c

Browse files
authored
Suspend automatic @icon check and resume acct removal in the interim (#1324)
* Apparently there is a long standing issue with EPROTO and this. Will need to dive in way deep and wait until it is fixed. * Project error trapping yielded no results * Altered to use *request* and same issue as denoted on the issue * Prevents the server trip from *node* builtin and other mentioned package. Applies to #1323 and post #1303 Auto-merge
1 parent 8d90bfa commit d15672c

File tree

1 file changed

+115
-113
lines changed

1 file changed

+115
-113
lines changed

controllers/scriptStorage.js

+115-113
Original file line numberDiff line numberDiff line change
@@ -1381,119 +1381,121 @@ exports.storeScript = function (aUser, aMeta, aBuf, aUpdate, aCallback) {
13811381

13821382
aInnerCallback(null);
13831383
},
1384-
function (aInnerCallback) {
1385-
// `@icon` validations
1386-
var icon = null;
1387-
var buffer = null;
1388-
var fn = null;
1389-
var dimensions = null;
1390-
var matches = null;
1391-
var data = null;
1392-
var rDataURIbase64 = /^data:image\/.+;base64,(.*)$/;
1393-
1394-
function acceptedImage(aDimensions) {
1395-
var maxX = 256; //px
1396-
var maxY = 256; //px
1397-
1398-
switch (aDimensions.type) {
1399-
case 'gif':
1400-
// fallthrough
1401-
case 'jpeg':
1402-
// fallthrough
1403-
case 'png':
1404-
// fallthrough
1405-
case 'svg':
1406-
// fallthrough
1407-
case 'ico':
1408-
if (dimensions.width <= maxX && dimensions.height <= maxY) {
1409-
return true;
1410-
}
1411-
}
1412-
return false;
1413-
}
1414-
1415-
icon = findMeta(aMeta, 'UserScript.icon.0.value');
1416-
if (icon) {
1417-
if (!isFQUrl(icon, false, true)) {
1418-
1419-
// Not a web url... reject
1420-
aInnerCallback(new statusError({
1421-
message: '`@icon` not a web url or image data URI in the UserScript metadata block.',
1422-
code: 400
1423-
}), null);
1424-
return;
1425-
}
1426-
1427-
// Test dimensions
1428-
if (/^data:/.test(icon)) {
1429-
matches = icon.match(rDataURIbase64);
1430-
if (matches) {
1431-
data = matches[1];
1432-
buffer = new Buffer(data, 'base64');
1433-
try {
1434-
dimensions = sizeOf(buffer);
1435-
} catch (aE) {
1436-
aInnerCallback(new statusError({
1437-
message: '`@icon` ' + aE.message,
1438-
code: aE.code
1439-
}));
1440-
return;
1441-
}
1442-
1443-
if (!acceptedImage(dimensions)) {
1444-
aInnerCallback(new statusError({
1445-
message: '`@icon` unsupported file type or dimensions are too large.',
1446-
code: 400
1447-
}), null);
1448-
} else {
1449-
aInnerCallback(null);
1450-
}
1451-
} else {
1452-
aInnerCallback(new statusError({
1453-
message: 'Invalid `@icon`',
1454-
code: 400
1455-
}), null);
1456-
}
1457-
} else {
1458-
fn = /^http:/.test(icon) ? http : https;
1459-
fn.get(URL.parse(icon), function (aRes) {
1460-
var chunks = [];
1461-
aRes.on('data', function (aChunk) {
1462-
var buf = null;
1463-
chunks.push(aChunk);
1464-
buf = Buffer.concat(chunks);
1465-
if (buf.length > 3048) { // NOTE: KiB
1466-
aRes.destroy();
1467-
}
1468-
}).on('end', function () {
1469-
buffer = Buffer.concat(chunks);
1470-
try {
1471-
dimensions = sizeOf(buffer);
1472-
} catch (aE) {
1473-
aInnerCallback(new statusError({
1474-
message: '`@icon` ' + aE.message,
1475-
code: aE.code
1476-
}));
1477-
return;
1478-
}
1479-
1480-
if (!acceptedImage(dimensions)) {
1481-
aInnerCallback(new statusError({
1482-
message: '`@icon` unsupported file type or dimensions are too large.',
1483-
code: 400
1484-
}), null);
1485-
} else {
1486-
aInnerCallback(null);
1487-
}
1488-
}).on('error', function (aErr) {
1489-
aInnerCallback(aErr);
1490-
});
1491-
});
1492-
}
1493-
} else {
1494-
aInnerCallback(null);
1495-
}
1496-
},
1384+
//
1385+
// See #1323
1386+
// function (aInnerCallback) {
1387+
// // `@icon` validations
1388+
// var icon = null;
1389+
// var buffer = null;
1390+
// var fn = null;
1391+
// var dimensions = null;
1392+
// var matches = null;
1393+
// var data = null;
1394+
// var rDataURIbase64 = /^data:image\/.+;base64,(.*)$/;
1395+
//
1396+
// function acceptedImage(aDimensions) {
1397+
// var maxX = 256; //px
1398+
// var maxY = 256; //px
1399+
//
1400+
// switch (aDimensions.type) {
1401+
// case 'gif':
1402+
// // fallthrough
1403+
// case 'jpeg':
1404+
// // fallthrough
1405+
// case 'png':
1406+
// // fallthrough
1407+
// case 'svg':
1408+
// // fallthrough
1409+
// case 'ico':
1410+
// if (dimensions.width <= maxX && dimensions.height <= maxY) {
1411+
// return true;
1412+
// }
1413+
// }
1414+
// return false;
1415+
// }
1416+
//
1417+
// icon = findMeta(aMeta, 'UserScript.icon.0.value');
1418+
// if (icon) {
1419+
// if (!isFQUrl(icon, false, true)) {
1420+
//
1421+
// // Not a web url... reject
1422+
// aInnerCallback(new statusError({
1423+
// message: '`@icon` not a web url or image data URI in the UserScript metadata block.',
1424+
// code: 400
1425+
// }), null);
1426+
// return;
1427+
// }
1428+
//
1429+
// // Test dimensions
1430+
// if (/^data:/.test(icon)) {
1431+
// matches = icon.match(rDataURIbase64);
1432+
// if (matches) {
1433+
// data = matches[1];
1434+
// buffer = new Buffer(data, 'base64');
1435+
// try {
1436+
// dimensions = sizeOf(buffer);
1437+
// } catch (aE) {
1438+
// aInnerCallback(new statusError({
1439+
// message: '`@icon` ' + aE.message,
1440+
// code: aE.code
1441+
// }));
1442+
// return;
1443+
// }
1444+
//
1445+
// if (!acceptedImage(dimensions)) {
1446+
// aInnerCallback(new statusError({
1447+
// message: '`@icon` unsupported file type or dimensions are too large.',
1448+
// code: 400
1449+
// }), null);
1450+
// } else {
1451+
// aInnerCallback(null);
1452+
// }
1453+
// } else {
1454+
// aInnerCallback(new statusError({
1455+
// message: 'Invalid `@icon`',
1456+
// code: 400
1457+
// }), null);
1458+
// }
1459+
// } else {
1460+
// fn = /^http:/.test(icon) ? http : https;
1461+
// fn.get(URL.parse(icon), function (aRes) {
1462+
// var chunks = [];
1463+
// aRes.on('data', function (aChunk) {
1464+
// var buf = null;
1465+
// chunks.push(aChunk);
1466+
// buf = Buffer.concat(chunks);
1467+
// if (buf.length > 3048) { // NOTE: KiB
1468+
// aRes.destroy();
1469+
// }
1470+
// }).on('end', function () {
1471+
// buffer = Buffer.concat(chunks);
1472+
// try {
1473+
// dimensions = sizeOf(buffer);
1474+
// } catch (aE) {
1475+
// aInnerCallback(new statusError({
1476+
// message: '`@icon` ' + aE.message,
1477+
// code: aE.code
1478+
// }));
1479+
// return;
1480+
// }
1481+
//
1482+
// if (!acceptedImage(dimensions)) {
1483+
// aInnerCallback(new statusError({
1484+
// message: '`@icon` unsupported file type or dimensions are too large.',
1485+
// code: 400
1486+
// }), null);
1487+
// } else {
1488+
// aInnerCallback(null);
1489+
// }
1490+
// }).on('error', function (aErr) {
1491+
// aInnerCallback(aErr);
1492+
// });
1493+
// });
1494+
// }
1495+
// } else {
1496+
// aInnerCallback(null);
1497+
// }
1498+
// },
14971499
function (aInnerCallback) {
14981500
// `@supportURL` validations
14991501
var supportURL = null;

0 commit comments

Comments
 (0)