瀏覽代碼

prevent large images

jomo 10 年之前
父節點
當前提交
77bcf9dbe7
共有 2 個文件被更改,包括 3 次插入5 次删除
  1. 2 4
      routes/avatars.js
  2. 1 1
      views/index.jade

+ 2 - 4
routes/avatars.js

@@ -9,10 +9,8 @@ var valid_uuid = /^[0-9a-f]{32}$/;
 router.get('/:uuid/:size?', function(req, res) {
   var uuid = req.param('uuid');
   var size = req.param('size') || 180;
-  // Add temporary restriction to prevent app from crashing
-  if (size <= 0) {
-    size = 180;
-  }
+  // Prevent app from crashing/freezing
+  if (size <= 0 || size > 512) size = 180;
   console.log(uuid);
   if (valid_uuid.test(uuid)) {
     var filename = uuid + ".png";

+ 1 - 1
views/index.jade

@@ -19,7 +19,7 @@ block content
 					| "&gt;
 				p(style="margin-top: 10px;") Example: UUID: '2d5aa9cdaeb049189930461fc9b91cc5', Username: Jake0oo0
 				.well &lt;img src="https://skins.jake0oo0.me/avatars/2d5aa9cdaeb049189930461fc9b91cc5"&gt;
-				p(style="margin-top: 10px;") There is also an option to include a size, default is 180x180px.
+				p(style="margin-top: 10px;") There is also an option to include a size, default is 180x180px. The size may not be larger than 512px.
 				.well
 					| &lt;img src="https://skins.jake0oo0.me/avatars/
 					mark.green uuid