Merge pull request #1969 from himikof/patch-1

Fix Metalink4 parsing with foreign namespaces
pull/1945/merge
Tatsuhiro Tsujikawa 2022-08-25 16:23:39 +09:00 committed by GitHub
commit f4cbc7bb31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -47,7 +47,7 @@ namespace aria2 {
const char METALINK4_NAMESPACE_URI[] = "urn:ietf:params:xml:ns:metalink";
namespace {
bool checkNsUri(const char* nsUri)
bool isMetalink4Ns(const char* nsUri)
{
return nsUri && strcmp(nsUri, METALINK4_NAMESPACE_URI) == 0;
}
@ -57,7 +57,7 @@ void MetalinkMetalinkParserStateV4::beginElement(
MetalinkParserStateMachine* psm, const char* localname, const char* prefix,
const char* nsUri, const std::vector<XmlAttr>& attrs)
{
if (checkNsUri(nsUri) && strcmp(localname, "file") != 0) {
if (!isMetalink4Ns(nsUri) || strcmp(localname, "file") != 0) {
psm->setSkipTagState();
return;
}
@ -83,7 +83,7 @@ void FileMetalinkParserStateV4::beginElement(MetalinkParserStateMachine* psm,
const char* nsUri,
const std::vector<XmlAttr>& attrs)
{
if (!checkNsUri(nsUri)) {
if (!isMetalink4Ns(nsUri)) {
psm->setSkipTagState();
}
else if (strcmp(localname, "size") == 0) {
@ -293,7 +293,7 @@ void PiecesMetalinkParserStateV4::beginElement(
MetalinkParserStateMachine* psm, const char* localname, const char* prefix,
const char* nsUri, const std::vector<XmlAttr>& attrs)
{
if (checkNsUri(nsUri) && strcmp(localname, "hash") == 0) {
if (isMetalink4Ns(nsUri) && strcmp(localname, "hash") == 0) {
psm->setPieceHashStateV4();
}
else {