From 945920f24dba53d8367160b221bc842db0768fc4 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sat, 5 Aug 2017 09:46:14 +0200 Subject: [PATCH] Mimetype was not recognized if longer than bare mime --- lib/util.php | 2 +- plugins/LRDD/lib/discovery.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/util.php b/lib/util.php index b67df923d9..d1d79d1282 100644 --- a/lib/util.php +++ b/lib/util.php @@ -2060,7 +2060,7 @@ function common_bare_mime($mimetype) if ($semicolon = mb_strpos($mimetype, ';')) { $mimetype = mb_substr($mimetype, 0, $semicolon); } - return $mimetype; + return trim($mimetype); } function common_mime_type_match($type, $avail) diff --git a/plugins/LRDD/lib/discovery.php b/plugins/LRDD/lib/discovery.php index a69d5b8ce2..5a1ec7969a 100644 --- a/plugins/LRDD/lib/discovery.php +++ b/plugins/LRDD/lib/discovery.php @@ -124,7 +124,7 @@ class Discovery throw new Exception('Unexpected HTTP status code.'); } - switch ($response->getHeader('content-type')) { + switch (common_bare_mime($response->getHeader('content-type'))) { case self::JRD_MIMETYPE_OLD: case self::JRD_MIMETYPE: $type = 'json'; @@ -134,7 +134,7 @@ class Discovery break; default: // fall back to letting XML_XRD auto-detect - common_debug('No recognized content-type header for resource descriptor body.'); + common_debug('No recognized content-type header for resource descriptor body on '._ve($xrd_uri)); $type = null; } $xrd->loadString($response->getBody(), $type);