зеркало из https://github.com/nextcloud/cookbook.git
Do no longer cut slashes and backslashes from recipe names
Signed-off-by: Christian Wolf <github@christianwolf.email>
This commit is contained in:
Родитель
714671ae13
Коммит
b031159230
|
@ -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));
|
||||
|
|
Загрузка…
Ссылка в новой задаче