added preserve_slashes functionality to cleanUpString, so we may have slashes in fractional ingredieents, issue # 262

This commit is contained in:
Tim Andrews 2020-06-18 22:44:31 -04:00
Родитель a719b7b1a6
Коммит 5f1a55d06b
1 изменённых файлов: 9 добавлений и 4 удалений

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

@ -275,7 +275,7 @@ class RecipeService
$ingredients = [];
foreach ($json['recipeIngredient'] as $i => $ingredient) {
$ingredient = $this->cleanUpString($ingredient);
$ingredient = $this->cleanUpString($ingredient, false, true);
if (!$ingredient) {
continue;
@ -1142,7 +1142,7 @@ class RecipeService
*
* @return string
*/
private function cleanUpString($str, $preserve_newlines = false)
private function cleanUpString($str, $preserve_newlines = false, $preserve_slashes = false)
{
if (!$str) {
return '';
@ -1154,7 +1154,12 @@ class RecipeService
$str = str_replace(["\r", "\n"], '', $str);
}
if (!$preserve_slashes) {
$str = str_replace(["\t", "\\"], '', $str);
}
else {
$str = str_replace(["\t", "\\", "/"], '', $str);
}
$str = html_entity_decode($str);