Signed-off-by: Christian Wolf <github@christianwolf.email>
This commit is contained in:
Christian Wolf 2021-01-23 17:49:56 +01:00
Родитель fe7533e753
Коммит 0f35d9a53d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 9FC3120E932F73F1
4 изменённых файлов: 8 добавлений и 13 удалений

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

@ -3,7 +3,7 @@
namespace OCA\Cookbook\Helper\HTMLFilter;
class HtmlEntiryDecodeFilter extends AbstractHtmlFilter {
public function apply(string $html): void {
public function apply(string &$html): void {
$html = html_entity_decode($html);
}
}

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

@ -19,6 +19,8 @@ class HttpJsonLdParser extends AbstractHtmlParser {
public function __construct(IL10N $l10n, JsonService $jsonService) {
parent::__construct($l10n);
$this->jsonService = $jsonService;
}
public function parse(\DOMDocument $document): array {

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

@ -199,32 +199,24 @@ class HtmlDownloadService {
/** @var \LibXMLError $error */
$error = $by_error_code[$code];
// Collect data for translations
$params = [];
$params['code'] = $error->code;
$params['count'] = $count;
$params['url'] = $url;
$params['line'] = $error->line;
$params['column'] = $error->column;
switch ($error->level) {
case LIBXML_ERR_WARNING:
$error_message = $this->l->t("Warning {code} occurred {count} times while parsing {url}.", $params);
$error_message = $this->l->t('Warning %u occurred %u times while parsing %s.', [$error->code, $count, $url]);
$return = max($return, self::PARSING_WARNING);
break;
case LIBXML_ERR_ERROR:
$error_message = $this->l->t("Error {code} occurred {count} times while parsing {url}.", $params);
$error_message = $this->l->t('Error %u occurred %u times while parsing %s.', [$error->code, $count, $url]);
$return = max($return, self::PARSING_ERROR);
break;
case LIBXML_ERR_FATAL:
$error_message = $this->l->t("Fatal error {code} occurred {count} times while parsing {url}.", $params);
$error_message = $this->l->t('Fatal error %u occurred %count$u times while parsing %s.', [$error->code, $count, $url]);
$return = max($return, self::PARSING_FATAL_ERROR);
break;
default:
throw new \Exception($this->l->t('Unsupported error level during parsing of XML output.'));
}
$last_occurence = $this->l->t('Last time it occurred in line {line} and column {column}', $params);
$last_occurence = $this->l->t('Last time it occurred in line %u and column %u', [$error->line, $error->column]);
$error_message = "libxml: $error_message $last_occurence: " . $error->message;
$this->logger->warning($error_message);

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

@ -23,6 +23,7 @@ class RecipeExtractionService {
public function __construct(HttpJsonLdParser $jsonParser, HttpMicrodataParser $microdataParser,
IL10N $l10n) {
$this->parsers = [$jsonParser, $microdataParser];
$this->l = $l10n;
}
/**