Escape space in attachment URLs with %20

Fixes issue #401
This commit is contained in:
Jan Böhmer 2023-10-15 00:50:43 +02:00
parent 180505cba4
commit f53c98312e
2 changed files with 30 additions and 0 deletions

View file

@ -472,6 +472,10 @@ abstract class Attachment extends AbstractNamedDBElement
#[SerializedName('url')]
public function setURL(?string $url): self
{
$url = trim($url);
//Escape spaces in URL
$url = str_replace(' ', '%20', $url);
//Only set if the URL is not empty
if ($url !== null && $url !== '') {
if (str_contains($url, '%BASE%') || str_contains($url, '%MEDIA%')) {