Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
235e38b69b | ||
|
|
279b2c120f | ||
|
|
c92a953511 | ||
|
|
863ae19d1d | ||
|
|
cd7b6d69b0 |
@@ -612,6 +612,14 @@ private:
|
|||||||
SG_LOG(SG_TERRASYNC, SG_WARN, "malformed .dirindex file: invalid type in line '" << line << "', expected 'd' or 'f', (ignoring line)" );
|
SG_LOG(SG_TERRASYNC, SG_WARN, "malformed .dirindex file: invalid type in line '" << line << "', expected 'd' or 'f', (ignoring line)" );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// security: prevent writing outside the repository via ../../.. filenames
|
||||||
|
// (valid filenames never contain / - subdirectories have their own .dirindex)
|
||||||
|
if ((tokens[1] == "..") || (tokens[1].find_first_of("/\\") != std::string::npos)) {
|
||||||
|
SG_LOG(SG_TERRASYNC, SG_WARN, "malformed .dirindex file: invalid filename in line '" << line << "', (ignoring line)" );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
children.push_back(ChildInfo(typeData == "f" ? ChildInfo::FileType : ChildInfo::DirectoryType, tokens[1], tokens[2]));
|
children.push_back(ChildInfo(typeData == "f" ? ChildInfo::FileType : ChildInfo::DirectoryType, tokens[1], tokens[2]));
|
||||||
|
|
||||||
if (tokens.size() > 3) {
|
if (tokens.size() > 3) {
|
||||||
|
|||||||
@@ -175,9 +175,14 @@ int parseTest()
|
|||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int skisVariantFull = p2->indexOfVariant("org.flightgear.test.catalog1.c172p-skis");
|
||||||
|
VERIFY(skisVariantFull > 0);
|
||||||
|
|
||||||
unsigned int skisVariant = p2->indexOfVariant("c172p-skis");
|
unsigned int skisVariant = p2->indexOfVariant("c172p-skis");
|
||||||
VERIFY(skisVariant > 0);
|
VERIFY(skisVariant > 0);
|
||||||
|
|
||||||
|
COMPARE(skisVariant, skisVariantFull);
|
||||||
|
|
||||||
pkg::Package::ThumbnailVec thumbs2 = p2->thumbnailsForVariant(skisVariant);
|
pkg::Package::ThumbnailVec thumbs2 = p2->thumbnailsForVariant(skisVariant);
|
||||||
COMPARE(thumbs2.size(), 2);
|
COMPARE(thumbs2.size(), 2);
|
||||||
|
|
||||||
|
|||||||
@@ -340,13 +340,25 @@ std::string Package::nameForVariant(const std::string& vid) const
|
|||||||
|
|
||||||
unsigned int Package::indexOfVariant(const std::string& vid) const
|
unsigned int Package::indexOfVariant(const std::string& vid) const
|
||||||
{
|
{
|
||||||
if (vid == id()) {
|
// accept fully-qualified IDs here
|
||||||
|
std::string actualId = vid;
|
||||||
|
size_t lastDot = vid.rfind('.');
|
||||||
|
if (lastDot != std::string::npos) {
|
||||||
|
std::string catalogId = vid.substr(0, lastDot);
|
||||||
|
if (catalogId != catalog()->id()) {
|
||||||
|
throw sg_exception("Bad fully-qualified ID:" + vid + ", package mismatch" );
|
||||||
|
}
|
||||||
|
actualId = vid.substr(lastDot + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (actualId == id()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int result = 1;
|
unsigned int result = 1;
|
||||||
for (SGPropertyNode* var : m_props->getChildren("variant")) {
|
for (SGPropertyNode* var : m_props->getChildren("variant")) {
|
||||||
if (var->getStringValue("id") == vid) {
|
if (var->getStringValue("id") == actualId) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user