зеркало из https://github.com/nextcloud/cookbook.git
Fixed some bugs in the code
Signed-off-by: Christian Wolf <github@christianwolf.email>
This commit is contained in:
Родитель
fe7533e753
Коммит
0f35d9a53d
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче