代码拉取完成,页面将自动刷新
同步操作将从 OpenHarmony/third_party_libxml2 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 4ad71c2d72beef0d10cf75aa417db10d77846f75 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Sat, 20 Aug 2022 16:19:34 +0200
Subject: [PATCH] Fix xmlCtxtReadDoc with encoding
xmlCtxtReadDoc used to create an input stream involving
xmlNewStringInputStream. This would create a stream without an input
buffer, causing problems with encodings (see #34).
After commit aab584dc3, an error was returned even with UTF-8 encodings
which happened to work before.
Make xmlCtxtReadDoc call xmlCtxtReadMemory which doesn't suffer from
these issues. Also fix htmlCtxtReadDoc.
Fixes #397.
Reference:https://github.com/GNOME/libxml2/commit/4ad71c2d72beef0d10cf75aa417db10d77846f75
Conflict:NA
---
HTMLparser.c | 17 ++++-------------
parser.c | 16 +++-------------
2 files changed, 7 insertions(+), 26 deletions(-)
diff --git a/HTMLparser.c b/HTMLparser.c
index 98d73f3..a4168f3 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -7087,22 +7087,13 @@ htmlDocPtr
htmlCtxtReadDoc(htmlParserCtxtPtr ctxt, const xmlChar * cur,
const char *URL, const char *encoding, int options)
{
- xmlParserInputPtr stream;
+ const char *buf;
if (cur == NULL)
return (NULL);
- if (ctxt == NULL)
- return (NULL);
- xmlInitParser();
-
- htmlCtxtReset(ctxt);
-
- stream = xmlNewStringInputStream(ctxt, cur);
- if (stream == NULL) {
- return (NULL);
- }
- inputPush(ctxt, stream);
- return (htmlDoRead(ctxt, URL, encoding, options, 1));
+ buf = (const char *) cur;
+ return (htmlCtxtReadMemory(ctxt, buf, strlen(buf), URL, encoding,
+ options));
}
/**
diff --git a/parser.c b/parser.c
index 6b04bbf..fbeb7af 100644
--- a/parser.c
+++ b/parser.c
@@ -15374,22 +15374,12 @@ xmlDocPtr
xmlCtxtReadDoc(xmlParserCtxtPtr ctxt, const xmlChar * cur,
const char *URL, const char *encoding, int options)
{
- xmlParserInputPtr stream;
+ const char *buf;
if (cur == NULL)
return (NULL);
- if (ctxt == NULL)
- return (NULL);
- xmlInitParser();
-
- xmlCtxtReset(ctxt);
-
- stream = xmlNewStringInputStream(ctxt, cur);
- if (stream == NULL) {
- return (NULL);
- }
- inputPush(ctxt, stream);
- return (xmlDoRead(ctxt, URL, encoding, options, 1));
+ buf = (const char *) cur;
+ return (xmlCtxtReadMemory(ctxt, buf, strlen(buf), URL, encoding, options));
}
/**
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。