mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-06 16:02:26 +02:00
* Update file handling to look for HTML ASCII codes which will cause uploads to fail
This commit is contained in:
parent
31fc6a4d4f
commit
14b2de8f4c
12
src/sync.d
12
src/sync.d
|
@ -861,6 +861,12 @@ final class SyncEngine
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for HTML ASCII Codes as part of file name
|
||||||
|
if (!containsASCIIHTMLCodes(path)) {
|
||||||
|
log.vlog("Skipping item - invalid name (Contains HTML ASCII Code): ", path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final switch (item.type) {
|
final switch (item.type) {
|
||||||
case ItemType.dir:
|
case ItemType.dir:
|
||||||
uploadDirDifferences(item, path);
|
uploadDirDifferences(item, path);
|
||||||
|
@ -1079,6 +1085,12 @@ final class SyncEngine
|
||||||
log.vlog("Skipping item - invalid name (Contains an invalid whitespace item): ", path);
|
log.vlog("Skipping item - invalid name (Contains an invalid whitespace item): ", path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for HTML ASCII Codes as part of file name
|
||||||
|
if (!containsASCIIHTMLCodes(path)) {
|
||||||
|
log.vlog("Skipping item - invalid name (Contains HTML ASCII Code): ", path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// filter out user configured items to skip
|
// filter out user configured items to skip
|
||||||
if (path != ".") {
|
if (path != ".") {
|
||||||
|
|
18
src/util.d
18
src/util.d
|
@ -210,18 +210,30 @@ bool containsBadWhiteSpace(string path)
|
||||||
// Check for the presence of '%0A' via regex
|
// Check for the presence of '%0A' via regex
|
||||||
|
|
||||||
string itemName = encodeComponent(baseName(path));
|
string itemName = encodeComponent(baseName(path));
|
||||||
|
|
||||||
auto invalidWhitespaceReg =
|
auto invalidWhitespaceReg =
|
||||||
ctRegex!(
|
ctRegex!(
|
||||||
// Check for \n which is %0A when encoded
|
// Check for \n which is %0A when encoded
|
||||||
`%0A`
|
`%0A`
|
||||||
);
|
);
|
||||||
auto m = match(itemName, invalidWhitespaceReg);
|
auto m = match(itemName, invalidWhitespaceReg);
|
||||||
|
|
||||||
return m.empty;
|
return m.empty;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool containsASCIIHTMLCodes(string path)
|
||||||
|
{
|
||||||
|
// https://github.com/abraunegg/onedrive/issues/151
|
||||||
|
// If a filename contains ASCII HTML codes, regardless of if it gets encoded, it generates an error
|
||||||
|
// Check if the filename contains an ASCII HTML code sequence
|
||||||
|
|
||||||
|
auto invalidASCIICode =
|
||||||
|
ctRegex!(
|
||||||
|
// Check to see if &#XXXX is in the filename
|
||||||
|
`(?:&#|&#[0-9][0-9]|&#[0-9][0-9][0-9]|&#[0-9][0-9][0-9][0-9])`
|
||||||
|
);
|
||||||
|
|
||||||
|
auto m = match(path, invalidASCIICode);
|
||||||
|
return m.empty;
|
||||||
|
}
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue