aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-12-25 02:45:22 -0800
committerfriendica <info@friendica.com>2013-12-25 02:45:22 -0800
commit4ec569d6e7ce5f114796d2a9e9f27fc945f0e61c (patch)
tree1b110c244487d8536a84bb1700e13de7d224e53d
parentc1875bcc37ea1e668ccd0821baacd8706142f543 (diff)
downloadvolse-hubzilla-4ec569d6e7ce5f114796d2a9e9f27fc945f0e61c.tar.gz
volse-hubzilla-4ec569d6e7ce5f114796d2a9e9f27fc945f0e61c.tar.bz2
volse-hubzilla-4ec569d6e7ce5f114796d2a9e9f27fc945f0e61c.zip
sslify http links in media elements if you're on an https server
-rwxr-xr-xinclude/text.php32
-rw-r--r--mod/sslify.php6
2 files changed, 38 insertions, 0 deletions
diff --git a/include/text.php b/include/text.php
index b3154d23e..8b71fbddf 100755
--- a/include/text.php
+++ b/include/text.php
@@ -781,6 +781,34 @@ function linkify($s) {
return($s);
}
+/**
+ * @function sslify($s)
+ * Replace media element using http url with https to a local redirector if using https locally
+ * @param string $s
+ *
+ * Looks for HTML tags containing src elements that are http when we're viewing an https page
+ * Typically this throws an insecure content violation in the browser. So we redirect them
+ * to a local redirector which uses https and which redirects to the selected content
+ *
+ * @returns string
+ */
+
+
+function sslify($s) {
+ if(strpos(z_root(),'https:') === false)
+ return $s;
+ $matches = null;
+ $cnt = preg_match_all("/\<(.*?)src=\"(http\:.*?)\"(.*?)\>/",$s,$matches,PREG_SET_ORDER);
+ if($cnt) {
+ foreach($matches as $match) {
+ $s = str_replace($match[2],z_root() . '/sslify?f=&url=' . urlencode($match[2]),$s);
+ }
+ }
+ return $s;
+}
+
+
+
function get_poke_verbs() {
// index is present tense verb
@@ -1166,6 +1194,10 @@ function prepare_body(&$item,$attach = false) {
if(local_user() == $item['uid'])
$s .= format_filer($item);
+
+ $s = sslify($s);
+
+
// Look for spoiler
$spoilersearch = '<blockquote class="spoiler">';
diff --git a/mod/sslify.php b/mod/sslify.php
new file mode 100644
index 000000000..951a201ea
--- /dev/null
+++ b/mod/sslify.php
@@ -0,0 +1,6 @@
+<?php
+
+function sslify_init(&$a) {
+ goaway($_REQUEST['url']);
+}
+