瀏覽代碼

Fix Dashboard Content-Length

Markus-Rost 4 年之前
父節點
當前提交
bc4d205665
共有 8 個文件被更改,包括 16 次插入16 次删除
  1. 1 1
      RcGcDb
  2. 1 1
      dashboard/guilds.js
  3. 1 1
      dashboard/index.js
  4. 2 2
      dashboard/oauth.js
  5. 3 3
      dashboard/rcscript.js
  6. 3 3
      dashboard/settings.js
  7. 1 1
      dashboard/util.js
  8. 4 4
      dashboard/verification.js

+ 1 - 1
RcGcDb

@@ -1 +1 @@
-Subproject commit 6db23b5ed61ae567b8263dc17cc1f390d0599df2
+Subproject commit e344316491e96d8329e4a028e64a767efcc9d289

+ 1 - 1
dashboard/guilds.js

@@ -200,7 +200,7 @@ function dashboard_guilds(res, state, reqURL, action, actionArgs) {
 		}
 	}
 	let body = $.html();
-	res.writeHead(200, {'Content-Length': body.length});
+	res.writeHead(200, {'Content-Length': Buffer.byteLength(body)});
 	res.write( body );
 	return res.end();
 }

+ 1 - 1
dashboard/index.js

@@ -99,7 +99,7 @@ const server = http.createServer((req, res) => {
 		let body = '<img width="400" src="https://http.cat/418"><br><strong>' + http.STATUS_CODES[418] + '</strong>';
 		res.writeHead(418, {
 			'Content-Type': 'text/html',
-			'Content-Length': body.length
+			'Content-Length': Buffer.byteLength(body)
 		});
 		res.write( body );
 		return res.end();

+ 2 - 2
dashboard/oauth.js

@@ -59,7 +59,7 @@ function dashboard_login(res, state, action) {
 			...( res.getHeader('Set-Cookie') || [] ),
 			`wikibot="${state}"; HttpOnly; Path=/`
 		],
-		'Content-Length': body.length
+		'Content-Length': Buffer.byteLength(body)
 	});
 	res.write( body );
 	return res.end();
@@ -262,7 +262,7 @@ function dashboard_api(res, input) {
 	} ).finally( () => {
 		let body = JSON.stringify(result);
 		res.writeHead(200, {
-			'Content-Length': body.length,
+			'Content-Length': Buffer.byteLength(body),
 			'Content-Type': 'application/json'
 		});
 		res.write( body );

+ 3 - 3
dashboard/rcscript.js

@@ -186,7 +186,7 @@ function dashboard_rcscript(res, $, guild, args, dashboardLang) {
 			$('#text code#server-id').text(guild.id);
 			$('.channel#rcscript').addClass('selected');
 			let body = $.html();
-			res.writeHead(200, {'Content-Length': body.length});
+			res.writeHead(200, {'Content-Length': Buffer.byteLength(body)});
 			res.write( body );
 			return res.end();
 		}
@@ -196,7 +196,7 @@ function dashboard_rcscript(res, $, guild, args, dashboardLang) {
 			$('#text code#server-id').text(guild.id);
 			$('.channel#rcscript').addClass('selected');
 			let body = $.html();
-			res.writeHead(200, {'Content-Length': body.length});
+			res.writeHead(200, {'Content-Length': Buffer.byteLength(body)});
 			res.write( body );
 			return res.end();
 		}
@@ -253,7 +253,7 @@ function dashboard_rcscript(res, $, guild, args, dashboardLang) {
 				$('#text code#server-id').text(guild.id);
 			}
 			let body = $.html();
-			res.writeHead(200, {'Content-Length': body.length});
+			res.writeHead(200, {'Content-Length': Buffer.byteLength(body)});
 			res.write( body );
 			return res.end();
 		} );

+ 3 - 3
dashboard/settings.js

@@ -178,7 +178,7 @@ function dashboard_settings(res, $, guild, args, dashboardLang) {
 			$('<p>').text(dashboardLang.get('settings.failed')).appendTo('#text .description');
 			$('.channel#settings').addClass('selected');
 			let body = $.html();
-			res.writeHead(200, {'Content-Length': body.length});
+			res.writeHead(200, {'Content-Length': Buffer.byteLength(body)});
 			res.write( body );
 			return res.end();
 		}
@@ -189,7 +189,7 @@ function dashboard_settings(res, $, guild, args, dashboardLang) {
 				prefix: process.env.prefix
 			}, defaultSettings), guild.roles).attr('action', `/guild/${guild.id}/settings/default`).appendTo('#text');
 			let body = $.html();
-			res.writeHead(200, {'Content-Length': body.length});
+			res.writeHead(200, {'Content-Length': Buffer.byteLength(body)});
 			res.write( body );
 			return res.end();
 		}
@@ -250,7 +250,7 @@ function dashboard_settings(res, $, guild, args, dashboardLang) {
 			createForm($, dashboardLang.get('settings.form.default'), dashboardLang, rows.find( row => !row.channel ), guild.roles).attr('action', `/guild/${guild.id}/settings/default`).appendTo('#text');
 		}
 		let body = $.html();
-		res.writeHead(200, {'Content-Length': body.length});
+		res.writeHead(200, {'Content-Length': Buffer.byteLength(body)});
 		res.write( body );
 		return res.end();
 	} );

+ 1 - 1
dashboard/util.js

@@ -158,7 +158,7 @@ function createNotice($, notice, dashboardLang, args = []) {
 		case 'sysmessage':
 			type = 'info';
 			title.text(dashboardLang.get('notice.sysmessage.title'));
-			text.text(dashboardLang.get('notice.sysmessage.text', true, $('<a target="_blank">').append(
+			text.html(dashboardLang.get('notice.sysmessage.text', true, $('<a target="_blank">').append(
 				$('<code>').text('MediaWiki:Custom-RcGcDw')
 			).attr('href', args[1]), $('<code class="user-select">').text(args[0])));
 			note = $('<a target="_blank">').text(args[1]).attr('href', args[1]);

+ 4 - 4
dashboard/verification.js

@@ -203,7 +203,7 @@ function dashboard_verification(res, $, guild, args, dashboardLang) {
 			$('#text code.prefix').prepend(escapeText(process.env.prefix));
 			$('.channel#verification').addClass('selected');
 			let body = $.html();
-			res.writeHead(200, {'Content-Length': body.length});
+			res.writeHead(200, {'Content-Length': Buffer.byteLength(body)});
 			res.write( body );
 			return res.end();
 		}
@@ -213,7 +213,7 @@ function dashboard_verification(res, $, guild, args, dashboardLang) {
 			$('#text code.prefix').prepend(escapeText(process.env.prefix));
 			$('.channel#verification').addClass('selected');
 			let body = $.html();
-			res.writeHead(200, {'Content-Length': body.length});
+			res.writeHead(200, {'Content-Length': Buffer.byteLength(body)});
 			res.write( body );
 			return res.end();
 		}
@@ -223,7 +223,7 @@ function dashboard_verification(res, $, guild, args, dashboardLang) {
 			$('#text code.prefix').prepend(escapeText(rows[0].prefix));
 			$('.channel#verification').addClass('selected');
 			let body = $.html();
-			res.writeHead(200, {'Content-Length': body.length});
+			res.writeHead(200, {'Content-Length': Buffer.byteLength(body)});
 			res.write( body );
 			return res.end();
 		}
@@ -268,7 +268,7 @@ function dashboard_verification(res, $, guild, args, dashboardLang) {
 			$('#text code.prefix').prepend(escapeText(prefix));
 		}
 		let body = $.html();
-		res.writeHead(200, {'Content-Length': body.length});
+		res.writeHead(200, {'Content-Length': Buffer.byteLength(body)});
 		res.write( body );
 		return res.end();
 	} );