Skip to content

Commit

Permalink
Log percent-encoded URL/filename
Browse files Browse the repository at this point in the history
This can be used to debug Unicode normalization/encoding issues.
  • Loading branch information
erikjv committed Nov 28, 2024
1 parent 83d7be7 commit d5d3463
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ void ProcessDirectoryJob::processFile(const PathTuple &path,
const LocalInfo &localEntry, const RemoteInfo &serverEntry,
const SyncJournalFileRecord &dbEntry)
{
// The percent-encoded file name as it would be passed in an HTTP request. This can be used to
// debug Unicode encoding/normalization issues.
auto encodedFileName = QUrl::fromLocalFile(path._original).toEncoded().sliced(std::string_view("file:").length());
const char *hasServer = serverEntry.isValid() ? "true" : _queryServer == ParentNotChanged ? "db" : "false";
const char *hasLocal = localEntry.isValid() ? "true" : _queryLocal == ParentNotChanged ? "db" : "false";
qCInfo(lcDisco).nospace() << "Processing " << path._original
Expand All @@ -319,7 +322,8 @@ void ProcessDirectoryJob::processFile(const PathTuple &path,
<< " | perm: " << dbEntry._remotePerm << "//" << serverEntry.remotePerm
<< " | fileid: " << dbEntry._fileId << "//" << serverEntry.fileId
<< " | inode: " << dbEntry._inode << "/" << localEntry.inode << "/"
<< " | type: " << dbEntry._type << "/" << localEntry.type << "/" << (serverEntry.isDirectory ? ItemTypeDirectory : ItemTypeFile);
<< " | type: " << dbEntry._type << "/" << localEntry.type << "/" << (serverEntry.isDirectory ? ItemTypeDirectory : ItemTypeFile)
<< " (" << encodedFileName << ")";

if (_discoveryData->isRenamed(path._original)) {
qCDebug(lcDisco) << "Ignoring renamed";
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/httplogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bool isTextBody(const QString &s)
struct HttpContext
{
HttpContext(const QNetworkRequest &request)
: originalUrl(request.url().toString())
: originalUrl(request.url().toEncoded())
, lastUrl(request.url())
, id(QString::fromUtf8(request.rawHeader(QByteArrayLiteral("X-Request-ID"))))
{
Expand All @@ -55,7 +55,7 @@ struct HttpContext
redirectUrls.append(url.toString());
}

const QString originalUrl;
const QByteArray originalUrl;
QUrl lastUrl;
QStringList redirectUrls;
const QString id;
Expand Down

0 comments on commit d5d3463

Please sign in to comment.