Skip to content

Commit

Permalink
Use base64url helpers in glide
Browse files Browse the repository at this point in the history
  • Loading branch information
marcorieser committed Dec 22, 2024
1 parent 271a14c commit 1bf5aac
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Http/Controllers/GlideController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function generateByUrl($url)
{
$this->validateSignature();

$url = base64_decode($url);
$url = Str::fromBase64Url($url);

return $this->createResponse($this->generateBy('url', $url));
}
Expand All @@ -90,7 +90,7 @@ public function generateByAsset($encoded)
{
$this->validateSignature();

$decoded = base64_decode($encoded);
$decoded = Str::fromBase64Url($encoded);

// The string before the first slash is the container
[$container, $path] = explode('/', $decoded, 2);
Expand Down
8 changes: 4 additions & 4 deletions src/Imaging/GlideUrlBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public function build($item, $params)

switch ($this->itemType()) {
case 'url':
$path = 'http/'.base64_encode($item);
$path = 'http/'.Str::toBase64Url($item);
$filename = Str::afterLast($item, '/');
break;
case 'asset':
$path = 'asset/'.base64_encode($this->item->containerId().'/'.$this->item->path());
$path = 'asset/'.Str::toBase64Url($this->item->containerId().'/'.$this->item->path());
$filename = Str::afterLast($this->item->path(), '/');
break;
case 'id':
$path = 'asset/'.base64_encode(str_replace('::', '/', $this->item));
$path = 'asset/'.Str::toBase64Url(str_replace('::', '/', $this->item));
break;
case 'path':
$path = URL::encode($this->item);
Expand All @@ -61,7 +61,7 @@ public function build($item, $params)

if (isset($params['mark']) && $params['mark'] instanceof Asset) {
$asset = $params['mark'];
$params['mark'] = 'asset::'.base64_encode($asset->containerId().'/'.$asset->path());
$params['mark'] = 'asset::'.Str::toBase64Url($asset->containerId().'/'.$asset->path());
}

return URL::prependSiteRoot($builder->getUrl($path, $params));
Expand Down
2 changes: 1 addition & 1 deletion src/Imaging/ImageGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private function setUpWatermark($watermark): string
private function getWatermarkFilesystemAndParam($item)
{
if (is_string($item) && Str::startsWith($item, 'asset::')) {
$decoded = base64_decode(Str::after($item, 'asset::'));
$decoded = Str::fromBase64Url(Str::after($item, 'asset::'));
[$container, $path] = explode('/', $decoded, 2);
$item = Assets::find($container.'::'.$path);
}
Expand Down

0 comments on commit 1bf5aac

Please sign in to comment.