Skip to content

Commit

Permalink
Merge pull request #817 from nextcloud/fix/801-trim-name
Browse files Browse the repository at this point in the history
Remove multiple strings and trim names
  • Loading branch information
christianlupus authored Oct 17, 2021
2 parents 90b827c + 8e47c8c commit a9abdf7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
[#815](https://github.com/nextcloud/cookbook/pull/815) @christianlupus
- Correct usage of EXIF data to rotate thumb images accordingly
[#816](https://github.com/nextcloud/cookbook/pull/816) @christianlupus
- Trim spaces from names of imported recipes
[#817](https://github.com/nextcloud/cookbook/pull/817) @christianlupus


## 0.9.5 - 2021-10-15
Expand Down
13 changes: 9 additions & 4 deletions lib/Service/RecipeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1242,18 +1242,23 @@ private function cleanUpString($str, $preserve_newlines = false, $remove_slashes
$str = strip_tags($str);

if (!$preserve_newlines) {
$str = str_replace(["\r", "\n"], '', $str);
$str = str_replace(["\r", "\n"], ' ', $str);
}

$str = str_replace("\t", ' ', $str);
$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 ($remove_slashes) {
$str = str_replace(["\t", "\\", "/"], '', $str);
} else {
$str = str_replace(["\t", "\\"], '', $str);
$str = str_replace('/', '_', $str);
}

$str = html_entity_decode($str);

// Remove duplicated spaces
$str = preg_replace('/ */', ' ', $str);
$str = trim($str);

return $str;
}
}

0 comments on commit a9abdf7

Please sign in to comment.