From 189ed76a621955e76b8e6228ac27e1a25788835e Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Thu, 7 Sep 2017 18:05:11 -0600 Subject: [PATCH] .onion/TOR clients are no longer served HTTPS --- lib/WOPI/DiscoveryManager.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/WOPI/DiscoveryManager.php b/lib/WOPI/DiscoveryManager.php index f0be9f0f..5c646f8a 100644 --- a/lib/WOPI/DiscoveryManager.php +++ b/lib/WOPI/DiscoveryManager.php @@ -89,6 +89,12 @@ class DiscoveryManager { $responseBody = $response->getBody(); $replaceWith = str_replace("hostname.host", $_SERVER['HTTP_HOST'], $this->config->getAppValue('richdocuments', 'wopi_url')); + + // Use plain HTTP for .onion/TOR + if (strpos($this->config->getAppValue('richdocuments', 'wopi_url'), ".onion") !== FALSE) { + $replaceWith = str_replace("https://", "http://", $replaceWith); + } + $responseBodyMangled = str_replace($this->config->getAppValue('richdocuments', 'wopi_internal_url'), $replaceWith, $responseBody); // Skylar: Disable saving too, we don't need it if we're not loading ever /*$file->putContent(