mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Use rawurlencode instead of urlencode to sanatize URL-unsafe characters returned by the info providers.
This commit is contained in:
parent
12e9497ccf
commit
a5d184baef
2 changed files with 2 additions and 2 deletions
|
@ -45,7 +45,7 @@ class FileDTO
|
|||
//Find all occurrences of non URL safe characters and replace them with their URL encoded version.
|
||||
//We only want to replace characters which can not have a valid meaning in a URL (what would break the URL).
|
||||
//Digikey provided some wrong URLs with a ^ in them, which is not a valid URL character. (https://github.com/Part-DB/Part-DB-server/issues/521)
|
||||
$this->url = preg_replace_callback('/[^a-zA-Z0-9_\-.$+!*();\/?:@=&#%]/', fn($matches) => urlencode($matches[0]), $url);
|
||||
$this->url = preg_replace_callback('/[^a-zA-Z0-9_\-.$+!*();\/?:@=&#%]/', fn($matches) => rawurlencode($matches[0]), $url);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class FileDTOTest extends TestCase
|
|||
|
||||
//Remaining URL unsafe characters must be escaped
|
||||
["test%5Ese", "test^se"],
|
||||
["test+se", "test se"],
|
||||
["test%20se", "test se"],
|
||||
["test%7Cse", "test|se"],
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue