From 3e35e20cc5d4d3d82291f76ddd0770d70b539a68 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Mon, 13 May 2019 07:52:49 -0400 Subject: [PATCH] Update sync.d (#493) * Add an encoding validation check before any path length checks are performed as if the path contains any invalid UTF-8 sequences, the path walk to establish valid path length will fail --- src/sync.d | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/sync.d b/src/sync.d index 52f4de82..3eee1c7e 100644 --- a/src/sync.d +++ b/src/sync.d @@ -6,6 +6,7 @@ import std.file, std.json, std.path; import std.regex; import std.stdio, std.string, std.uni, std.uri; import std.conv; +import std.encoding; import core.time, core.thread; import core.stdc.stdlib; import config, itemdb, onedrive, selective, upload, util; @@ -1578,6 +1579,15 @@ final class SyncEngine return; } + // Invalid UTF-8 sequence check + // https://github.com/skilion/onedrive/issues/57 + // https://github.com/abraunegg/onedrive/issues/487 + if(!isValid(path)) { + // Path is not valid according to https://dlang.org/phobos/std_encoding.html + log.vlog("Skipping item - invalid character sequences: ", path); + return; + } + if(path.byGrapheme.walkLength < maxPathLength){ // path is less than maxPathLength