Skip to content

Commit f524041

Browse files
OmniTroidclaude
andcommitted
Fix webcache download loop and reject malformed paths
- Track failed downloads to avoid retrying them infinitely within a session - Reject paths containing absolute paths (starting with /, containing //, or :/) to prevent malformed URLs like "evidence//Users/..." Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 62a911f commit f524041

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

src/webcache.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ void WebCache::resolveOrDownload(const QString &relativePath, const QStringList
7070
return;
7171
}
7272

73+
// Reject paths containing absolute paths (they shouldn't be passed to webcache)
74+
// Check for Unix absolute paths embedded anywhere, or Windows drive letters
75+
if (relativePath.startsWith('/') || relativePath.contains("//") || relativePath.contains(":/"))
76+
{
77+
return;
78+
}
79+
7380
// Check if webcache is enabled
7481
if (!Options::getInstance().webcacheEnabled())
7582
{
@@ -95,6 +102,12 @@ void WebCache::resolveOrDownload(const QString &relativePath, const QStringList
95102
return;
96103
}
97104

105+
// Check if this path previously failed (don't retry within this session)
106+
if (m_failed_downloads.contains(relativePath))
107+
{
108+
return;
109+
}
110+
98111
// Try each suffix
99112
for (const QString &suffix : suffixes)
100113
{
@@ -140,6 +153,7 @@ void WebCache::onDownloadFinished(QNetworkReply *reply)
140153
if (reply->error() != QNetworkReply::NoError)
141154
{
142155
qDebug() << "WebCache: Download failed for" << reply->url().toString() << "-" << reply->errorString();
156+
m_failed_downloads.insert(relativePath);
143157
reply->deleteLater();
144158
return;
145159
}
@@ -149,6 +163,7 @@ void WebCache::onDownloadFinished(QNetworkReply *reply)
149163
if (statusCode != 200)
150164
{
151165
qDebug() << "WebCache: Download returned status" << statusCode << "for" << reply->url().toString();
166+
m_failed_downloads.insert(relativePath);
152167
reply->deleteLater();
153168
return;
154169
}

src/webcache.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <QNetworkAccessManager>
77
#include <QNetworkReply>
88
#include <QObject>
9+
#include <QSet>
910
#include <QString>
1011
#include <QVector>
1112

@@ -66,6 +67,9 @@ private Q_SLOTS:
6667
// Key: relative path, Value: list of suffixes being tried
6768
QHash<QString, bool> m_pending_downloads;
6869

70+
// Track failed downloads to avoid retrying them repeatedly
71+
QSet<QString> m_failed_downloads;
72+
6973
/**
7074
* @brief Initiates an async download for the given remote URL.
7175
* @param remoteUrl The full URL to download from.

0 commit comments

Comments
 (0)