Do no longer cut slashes and backslashes from recipe names

Signed-off-by: Christian Wolf <github@christianwolf.email>
This commit is contained in:
Christian Wolf 2024-05-21 17:04:07 +02:00
Родитель 714671ae13
Коммит b031159230
3 изменённых файлов: 7 добавлений и 4 удалений

Просмотреть файл

@ -22,7 +22,7 @@ class RecipeNameFilter extends AbstractJSONFilter {
public function apply(array &$json): bool {
// Clean up name to prevent issues
$cleanedName = $this->textCleanupHelper->cleanUp($json['name'], true, true);
$cleanedName = $this->textCleanupHelper->cleanUp($json['name'], true, false, false);
$changed = ($json['name'] !== $cleanedName);
// Restrict length of name

Просмотреть файл

@ -14,7 +14,8 @@ class TextCleanupHelper {
public function cleanUp(
?string $str,
bool $removeNewlines = true,
bool $removeSlashes = false
bool $removeSlashes = false,
bool $removeBackslashes = true
): string {
if (!$str) {
return '';
@ -27,7 +28,9 @@ class TextCleanupHelper {
}
$str = str_replace("\t", ' ', $str);
$str = str_replace("\\", '_', $str);
if($removeBackslashes) {
$str = str_replace("\\", '_', $str);
}
// We want to remove forward-slashes for the name of the recipe, to tie it to the directory structure, which cannot have slashes
if ($removeSlashes) {

Просмотреть файл

@ -47,7 +47,7 @@ class RecipeNameFilterTest extends TestCase {
$recipe['name'] = $oldName;
$this->textCleaner->method('cleanUp')->willReturnMap([
[$oldName, true, true, $retCleaning],
[$oldName, true, false, false, $retCleaning],
]);
$this->assertEquals($isChanged, $this->dut->apply($recipe));