mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-23 16:12:12 +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;
|
||||
}
|
||||
|
||||
// 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) {
|
||||
case ItemType.dir:
|
||||
uploadDirDifferences(item, path);
|
||||
|
@ -1080,6 +1086,12 @@ final class SyncEngine
|
|||
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
|
||||
if (path != ".") {
|
||||
if (selectiveSync.isNameExcluded(baseName(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
|
||||
|
||||
string itemName = encodeComponent(baseName(path));
|
||||
|
||||
auto invalidWhitespaceReg =
|
||||
ctRegex!(
|
||||
// Check for \n which is %0A when encoded
|
||||
`%0A`
|
||||
);
|
||||
auto m = match(itemName, invalidWhitespaceReg);
|
||||
|
||||
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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue