summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2017-07-13 08:57:31 +0300
committerAndrew Dolgov <[email protected]>2017-07-13 08:57:31 +0300
commite6d77d2b29e0b177bc5273fa90a99eacb1302b52 (patch)
tree0c60d2ba7c7fc8001530606897e8378d08888245 /include
parentb465c28ee038f93440ebb13ebfbbf529fd8149c7 (diff)
parentc9040c5c2e3960cd3668dd0cfe7621c5536ed37e (diff)
Merge branch 'master' of git.fakecake.org:tt-rss
Diffstat (limited to 'include')
-rw-r--r--include/functions.php13
-rwxr-xr-xinclude/sanity_check.php11
2 files changed, 13 insertions, 11 deletions
diff --git a/include/functions.php b/include/functions.php
index f29056077..ad6f2689c 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -1528,7 +1528,6 @@
$doc->loadHTML($charset_hack . $res);
$xpath = new DOMXPath($doc);
- $ttrss_uses_https = parse_url(get_self_url_prefix(), PHP_URL_SCHEME) === 'https';
$rewrite_base_url = $site_url ? $site_url : get_self_url_prefix();
$entries = $xpath->query('(//a[@href]|//img[@src]|//video/source[@src]|//audio/source[@src])');
@@ -1578,7 +1577,7 @@
if ($entry->hasAttribute('src')) {
$is_https_url = parse_url($entry->getAttribute('src'), PHP_URL_SCHEME) === 'https';
- if ($ttrss_uses_https && !$is_https_url) {
+ if (is_prefix_https() && !$is_https_url) {
if ($entry->hasAttribute('srcset')) {
$entry->removeAttribute('srcset');
@@ -1619,7 +1618,7 @@
if (!iframe_whitelisted($entry)) {
$entry->setAttribute('sandbox', 'allow-scripts');
} else {
- if ($_SERVER['HTTPS'] == "on") {
+ if (is_prefix_https()) {
$entry->setAttribute("src",
str_replace("http://", "https://",
$entry->getAttribute("src")));
@@ -1782,6 +1781,14 @@
return $tag;
}
+ function is_server_https() {
+ return $_SERVER['HTTPS'] == 'on' || $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https';
+ }
+
+ function is_prefix_https() {
+ return parse_url(SELF_URL_PATH, PHP_URL_SCHEME) == 'https';
+ }
+
// this returns SELF_URL_PATH sans ending slash
function get_self_url_prefix() {
if (strrpos(SELF_URL_PATH, "/") === strlen(SELF_URL_PATH)-1) {
diff --git a/include/sanity_check.php b/include/sanity_check.php
index 2f5315edf..964dce03c 100755
--- a/include/sanity_check.php
+++ b/include/sanity_check.php
@@ -15,7 +15,8 @@
* to get out. */
function make_self_url_path() {
- $url_path = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
+ $proto = is_server_https() ? 'https' : 'http';
+ $url_path = $proto . '://' . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
return $url_path;
}
@@ -107,7 +108,7 @@
if (isset($_SERVER["HTTP_HOST"]) &&
(!defined('_SKIP_SELF_URL_PATH_CHECKS') || !_SKIP_SELF_URL_PATH_CHECKS) &&
- SELF_URL_PATH != $ref_self_url_path && SELF_URL_PATH != mb_substr($ref_self_url_path, 0, mb_strlen($ref_self_url_path)-1)) {
+ SELF_URL_PATH != $ref_self_url_path && SELF_URL_PATH != mb_substr($ref_self_url_path, 0, mb_strlen($ref_self_url_path)-1)) {
array_push($errors,
"Please set SELF_URL_PATH to the correct value detected for your server: <b>$ref_self_url_path</b>");
}
@@ -151,12 +152,6 @@
if (!class_exists("DOMDocument")) {
array_push($errors, "PHP support for DOMDocument is required, but was not found.");
}
-
- $self_scheme = parse_url(SELF_URL_PATH, PHP_URL_SCHEME);
-
- if ($_SERVER['HTTPS'] && $self_scheme == 'http') {
- array_push($errors, "You are accessing tt-rss over SSL but SELF_URL_PATH in config.php refers to a http:// URL.");
- }
}
if (count($errors) > 0 && $_SERVER['REQUEST_URI']) { ?>