mirror of https://github.com/aria2/aria2
2010-02-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Store name attribute of metalink:metaurl element in MetalinkMetaurl. * src/MetalinkMetaurl.h * src/MetalinkParserController.cc * src/MetalinkParserController.h * src/MetalinkParserStateMachine.cc * src/MetalinkParserStateMachine.h * src/MetalinkParserStateV4Impl.cc * test/MetalinkProcessorTest.cc * test/metalink4-dirtraversal.xmlpull/1/head
parent
15c1f64023
commit
5032394c6a
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2010-02-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Store name attribute of metalink:metaurl element in MetalinkMetaurl.
|
||||||
|
* src/MetalinkMetaurl.h
|
||||||
|
* src/MetalinkParserController.cc
|
||||||
|
* src/MetalinkParserController.h
|
||||||
|
* src/MetalinkParserStateMachine.cc
|
||||||
|
* src/MetalinkParserStateMachine.h
|
||||||
|
* src/MetalinkParserStateV4Impl.cc
|
||||||
|
* test/MetalinkProcessorTest.cc
|
||||||
|
* test/metalink4-dirtraversal.xml
|
||||||
|
|
||||||
2010-02-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-02-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Added MetalinkMetaurl class. It corresponds to metalink:metaurl
|
Added MetalinkMetaurl class. It corresponds to metalink:metaurl
|
||||||
|
|
|
@ -46,6 +46,7 @@ public:
|
||||||
std::string url;
|
std::string url;
|
||||||
std::string mediatype;
|
std::string mediatype;
|
||||||
int priority;
|
int priority;
|
||||||
|
std::string name;
|
||||||
|
|
||||||
MetalinkMetaurl();
|
MetalinkMetaurl();
|
||||||
|
|
||||||
|
|
|
@ -567,6 +567,14 @@ void MetalinkParserController::setPriorityOfMetaurl(int priority)
|
||||||
_tMetaurl->priority = priority;
|
_tMetaurl->priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MetalinkParserController::setNameOfMetaurl(const std::string& name)
|
||||||
|
{
|
||||||
|
if(_tMetaurl.isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_tMetaurl->name = name;
|
||||||
|
}
|
||||||
|
|
||||||
void MetalinkParserController::commitMetaurlTransaction()
|
void MetalinkParserController::commitMetaurlTransaction()
|
||||||
{
|
{
|
||||||
if(_tMetaurl.isNull()) {
|
if(_tMetaurl.isNull()) {
|
||||||
|
|
|
@ -187,6 +187,8 @@ public:
|
||||||
|
|
||||||
void setPriorityOfMetaurl(int priority);
|
void setPriorityOfMetaurl(int priority);
|
||||||
|
|
||||||
|
void setNameOfMetaurl(const std::string& name);
|
||||||
|
|
||||||
void commitMetaurlTransaction();
|
void commitMetaurlTransaction();
|
||||||
|
|
||||||
void cancelMetaurlTransaction();
|
void cancelMetaurlTransaction();
|
||||||
|
|
|
@ -475,6 +475,11 @@ void MetalinkParserStateMachine::setPriorityOfMetaurl(int priority)
|
||||||
_ctrl->setPriorityOfMetaurl(priority);
|
_ctrl->setPriorityOfMetaurl(priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MetalinkParserStateMachine::setNameOfMetaurl(const std::string& name)
|
||||||
|
{
|
||||||
|
_ctrl->setNameOfMetaurl(name);
|
||||||
|
}
|
||||||
|
|
||||||
void MetalinkParserStateMachine::commitMetaurlTransaction()
|
void MetalinkParserStateMachine::commitMetaurlTransaction()
|
||||||
{
|
{
|
||||||
_ctrl->commitMetaurlTransaction();
|
_ctrl->commitMetaurlTransaction();
|
||||||
|
|
|
@ -237,6 +237,8 @@ public:
|
||||||
|
|
||||||
void setPriorityOfMetaurl(int priority);
|
void setPriorityOfMetaurl(int priority);
|
||||||
|
|
||||||
|
void setNameOfMetaurl(const std::string& name);
|
||||||
|
|
||||||
void commitMetaurlTransaction();
|
void commitMetaurlTransaction();
|
||||||
|
|
||||||
void cancelMetaurlTransaction();
|
void cancelMetaurlTransaction();
|
||||||
|
|
|
@ -130,6 +130,16 @@ void FileMetalinkParserStateV4::beginElement
|
||||||
stm->setOSStateV4();
|
stm->setOSStateV4();
|
||||||
} else if(localname == METAURL) {
|
} else if(localname == METAURL) {
|
||||||
stm->setMetaurlStateV4();
|
stm->setMetaurlStateV4();
|
||||||
|
std::string name;
|
||||||
|
{
|
||||||
|
std::vector<XmlAttr>::const_iterator itr = findAttr(attrs, NAME);
|
||||||
|
if(itr != attrs.end()) {
|
||||||
|
name = (*itr).value;
|
||||||
|
if(util::detectDirTraversal(name)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// TODO currently NAME is ignored
|
// TODO currently NAME is ignored
|
||||||
int priority;
|
int priority;
|
||||||
{
|
{
|
||||||
|
@ -159,6 +169,7 @@ void FileMetalinkParserStateV4::beginElement
|
||||||
stm->newMetaurlTransaction();
|
stm->newMetaurlTransaction();
|
||||||
stm->setPriorityOfMetaurl(priority);
|
stm->setPriorityOfMetaurl(priority);
|
||||||
stm->setMediatypeOfMetaurl(mediatype);
|
stm->setMediatypeOfMetaurl(mediatype);
|
||||||
|
stm->setNameOfMetaurl(name);
|
||||||
} else if(localname == URL) {
|
} else if(localname == URL) {
|
||||||
stm->setURLStateV4();
|
stm->setURLStateV4();
|
||||||
std::string location;
|
std::string location;
|
||||||
|
|
|
@ -135,7 +135,9 @@ void MetalinkProcessorTest::testParseFileV4_dirtraversal()
|
||||||
{
|
{
|
||||||
MetalinkProcessor proc;
|
MetalinkProcessor proc;
|
||||||
SharedHandle<Metalinker> m = proc.parseFile("metalink4-dirtraversal.xml");
|
SharedHandle<Metalinker> m = proc.parseFile("metalink4-dirtraversal.xml");
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)0, m->entries.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)1, m->entries.size());
|
||||||
|
CPPUNIT_ASSERT_EQUAL((size_t)0, m->entries[0]->resources.size());
|
||||||
|
CPPUNIT_ASSERT_EQUAL((size_t)0, m->entries[0]->metaurls.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkProcessorTest::testParseFileV4_attrs()
|
void MetalinkProcessorTest::testParseFileV4_attrs()
|
||||||
|
|
|
@ -21,4 +21,7 @@
|
||||||
<file name="..">
|
<file name="..">
|
||||||
<url location="fr" priority="1">http://example.com/example.ext</url>
|
<url location="fr" priority="1">http://example.com/example.ext</url>
|
||||||
</file>
|
</file>
|
||||||
|
<file name="foo">
|
||||||
|
<metaurl name="../foo" mediatype="torrent">http://example.com/example.torrent</metaurl>
|
||||||
|
</file>
|
||||||
</metalink>
|
</metalink>
|
||||||
|
|
Loading…
Reference in New Issue