Skip to content

Commit

Permalink
Add more check on backup folder
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueMatthew committed Oct 11, 2021
1 parent 32ce128 commit 8d09af0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion WechatExporter/core/ITunesParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ bool ManifestParser::parse(std::vector<BackupManifest>& manifests) const
bool res = false;

std::string path = normalizePath(m_manifestPath);
if (endsWith(path, normalizePath("/MobileSync")) || endsWith(path, normalizePath("/MobileSync/")))
if (endsWith(path, normalizePath("/MobileSync")) || endsWith(path, normalizePath("/MobileSync/")) || isValidMobileSync(path))
{
path = combinePath(path, "Backup");
res = parseDirectory(path, manifests);
Expand Down Expand Up @@ -671,6 +671,18 @@ bool ManifestParser::isValidBackupItem(const std::string& path) const
return true;
}

bool ManifestParser::isValidMobileSync(const std::string& path) const
{
std::string backupPath = combinePath(path, "Backup");
if (!existsFile(backupPath))
{
m_lastError += "Backup folder not found\r\n";
return false;
}

return true;
}

bool ManifestParser::parse(const std::string& path, BackupManifest& manifest) const
{
//Info.plist is a xml file
Expand Down
1 change: 1 addition & 0 deletions WechatExporter/core/ITunesParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ class ManifestParser
bool parseDirectory(const std::string& path, std::vector<BackupManifest>& manifests) const;
bool parse(const std::string& path, BackupManifest& manifest) const;
bool isValidBackupItem(const std::string& path) const;
bool isValidMobileSync(const std::string& path) const;

static bool parseInfoPlist(const std::string& backupIdPath, BackupManifest& manifest);
};
Expand Down

0 comments on commit 8d09af0

Please sign in to comment.