Commit 5f2dc258 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Gerrit Code Review

Merge "Bug 1843513: Allow for 'normal' a href links not to change to https"

parents 117de2fd c3677ec5
......@@ -4,11 +4,25 @@ class HTMLPurifier_URIFilter_MixedContent extends HTMLPurifier_URIFilter {
public $name = 'MixedContent';
public function filter(&$uri, $config, $context) {
// Make sure that if we're an HTTPS site, the iframe is also HTTPS
if (is_https() && $uri->scheme == 'http') {
// Convert it to a protocol-relative URL
$uri->scheme = null;
}
return $uri;
$currenttoken = $context->get('CurrentToken');
// Make sure that if we're an HTTPS site, then the URI link is also HTTPS
// Unless the link is a static <A HREF> link
$fixscheme = true;
if ($currenttoken->name == 'a') {
if (isset($currenttoken->attr) &&
isset($currenttoken->attr['class']) &&
preg_match('/embedly-card/', $currenttoken->attr['class'])) {
$fixscheme = true;
}
else {
$fixscheme = false;
}
}
if (is_https() && $uri->scheme == 'http' && $fixscheme) {
// Convert it to a protocol-relative URL
$uri->scheme = null;
}
return $uri;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment