Browse Source

pass extended link images via imgproxy; normalize // urls

Andrew Dolgov 1 year ago
parent
commit
17acafbfe8
2 changed files with 8 additions and 1 deletions
  1. 4 0
      backend.php
  2. 4 1
      js/tt-irc.js

+ 4 - 0
backend.php

@@ -830,6 +830,8 @@
 
 				$memcache->set($req_key, PROXY_REQ_PROGRESS, CACHE_LIFETIME_MAX);
 
+				if (strpos($url, "//") === 0) $url = "https:" . $url;
+
 				$ctx = stream_context_create($options);
 				$data = @file_get_contents($url, false, $ctx);
 
@@ -968,6 +970,8 @@
 				$options['http']['proxy'] = _HTTP_PROXY;
 			}
 
+			if (strpos($url, "//") === 0) $url = "https:" . $url;
+
 			$ctx = stream_context_create($options);
 			$data = @file_get_contents($url, false, $ctx);
 

+ 4 - 1
js/tt-irc.js

@@ -201,10 +201,13 @@ var Message = function(data, chan) {
 					var innerbox = $("<div>")
 						.attr("class", "inner-box")
 
+					var real_src = "backend.php?op=imgproxy&resize="+IMAGE_THUMB+"&url=" +
+						param_escape(json.image);
+
 					var thumb = $("<img>")
 						.attr("class", "img-embed img-responsive")
 						.attr("referrerpolicy", "no-referrer")
-						.attr("src", json.image);
+						.attr("src", real_src);
 
 					var thumb_link = $("<a>")
 						.attr("class", "thumb-link")