Skip to content

Commit

Permalink
MDL-73868 oauth2: Remove multiple slashes in image URL
Browse files Browse the repository at this point in the history
There is an issue with the current Badgr manifest because the image
URL contains double slash which is causing an error when storing it
in the database (https://api.test.badgr.com/static//images/logo.png).
This issue parses image URL and removes multiple slashes in URL.
  • Loading branch information
sarjona committed Feb 14, 2022
1 parent d24a4ab commit c4e6ac5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/classes/oauth2/discovery/imsbadgeconnect.php
Expand Up @@ -76,6 +76,8 @@ protected static function process_configuration_json(issuer $issuer, stdClass $i
} else if ($key == 'image' && empty($issuer->get('image'))) {
// Update the image with the value in the manifest file if it's valid and empty in the issuer.
$url = filter_var($value, FILTER_SANITIZE_URL);
// Remove multiple slashes in URL. It will fix the Badgr bug with image URL defined in their manifest.
$url = preg_replace('/([^:])(\/{2,})/', '$1/', $url);
if (filter_var($url, FILTER_VALIDATE_URL) !== false) {
$issuer->set('image', $url);
$issuer->update();
Expand Down

0 comments on commit c4e6ac5

Please sign in to comment.