nextcloud / nextcloud/cookbook

Can't parse recipe from JSON-LD with "

Open
#1,077 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Backend bug dependent php
Dominant language
HTML
Stars
641
Forks
113
Avg merge
21h 31m
Merged PRs (30d)
26

Description

Description
Due to too eager HtmlEntityDecodeFilter behavior recipes, containing " somewhere cannot be added from URL, because it converts " to " and brokes resulting JSON.

Reproduction
Steps to reproduce the behavior:

  1. Go to main page of cookbook
  2. Enter https://www.vkusnyblog.ru/recipe/myatnyj-limonad/ into «Download recipe from URL»
  3. Click on arrow
  4. See parsing error

Expected behavior
Recipe should be added

Actual behavior
Instead of recipe error appears


As workaround I propose to add ENT_NOQUOTES flag to HtmlEntityDecodeFilter, like this:

class HtmlEntityDecodeFilter extends AbstractHtmlFilter {
	public function apply(string &$html): void {
		$html = html_entity_decode($html, ENT_NOQUOTES);
	}
}

More correct fix will require some refactoring: IMHO, this filter should be applied only to all text fields in recipe instead of applying to raw data.


Depends on #1110

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the HtmlEntityDecodeFilter class and the URL recipe-import path described in the reproduction. Use the provided vkusnyblog.ru URL to reproduce the JSON-LD parsing error, then verify that recipes containing " are imported successfully without breaking the JSON; consider the dependency on #1110 before proceeding.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.