allow redirects on Bridgy, Bridgy Fed, and appspot.com
fixes #118. as far as we can tell, this is probably the root cause of many of these bugs filed against webmention.io over the last couple years, https://github.com/aaronpk/webmention.io/issues , eg #188, #187, #175, #173, etc.
@aaronpk [said](https://chat.indieweb.org/dev/2023-08-07#t1691382116891200):
> That was apparently added 8 years ago
> i vaguely remember some old issue with appspot URLs that I had to work around
that appspot URL issue was probably that it required SNI for SSL, which was less supported then, and much more widely supported now, so I'm pretty sure this change is ok.
cc @osa_k
1 year ago allow redirects on Bridgy, Bridgy Fed, and appspot.com
fixes #118. as far as we can tell, this is probably the root cause of many of these bugs filed against webmention.io over the last couple years, https://github.com/aaronpk/webmention.io/issues , eg #188, #187, #175, #173, etc.
@aaronpk [said](https://chat.indieweb.org/dev/2023-08-07#t1691382116891200):
> That was apparently added 8 years ago
> i vaguely remember some old issue with appspot URLs that I had to work around
that appspot URL issue was probably that it required SNI for SSL, which was less supported then, and much more widely supported now, so I'm pretty sure this change is ok.
cc @osa_k
1 year ago |
|
- <?php
- namespace p3k\XRay;
-
- function view($template, $data=[]) {
- global $templates;
- return $templates->render($template, $data);
- }
-
- // Adds slash if no path is in the URL, and convert hostname to lowercase
- function normalize_url($url) {
- $parts = parse_url($url);
- if(empty($parts['path']))
- $parts['path'] = '/';
- if(isset($parts['host']))
- $parts['host'] = strtolower($parts['host']);
- return build_url($parts);
- }
-
- function normalize_urls($urls) {
- return array_map('\p3k\XRay\normalize_url', $urls);
- }
-
- function urls_are_equal($url1, $url2) {
- $url1 = normalize_url($url1);
- $url2 = normalize_url($url2);
- return $url1 == $url2;
- }
-
- function build_url($parsed_url) {
- $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
- $host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
- $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
- $user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
- $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
- $pass = ($user || $pass) ? "$pass@" : '';
- $path = isset($parsed_url['path']) ? $parsed_url['path'] : '';
- $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
- $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
- return "$scheme$user$pass$host$port$path$query$fragment";
- }
-
- function should_follow_redirects($url) {
- $host = parse_url($url, PHP_URL_HOST);
- if(preg_match('/blogspot\.com|youtube\.com/', $host)) {
- return false;
- } else {
- return true;
- }
- }
-
- function phpmf2_version() {
- $composer = json_decode(file_get_contents(dirname(__FILE__).'/../composer.lock'));
- $version = 'unknown';
- foreach($composer->packages as $pkg) {
- if($pkg->name == 'mf2/mf2') {
- $version = $pkg->version;
- }
- }
- return $version;
- }
-
- function allow_iframe_video($value = NULL) {
- static $allow_iframe_video = false;
-
- if (isset($value))
- $allow_iframe_video = $value;
-
- return $allow_iframe_video;
- }
|