mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-16 12:45:14 +02:00
Update regular expression for invalid patterns
* Update regular expression for invalid patterns for efficiency * Update table title
This commit is contained in:
parent
3c44f7d2d9
commit
35ebdc87d4
|
@ -103,7 +103,7 @@ Should a file or folder infringe upon these naming conventions or restrictions,
|
|||
|
||||
> [!TIP]
|
||||
> UTF-16 provides a capability to use UTF-16 characters to work around the restrictions and limitations imposed by Microsoft OneDrive. An example of some replacement characters are below:
|
||||
> | Standard Character | UTF-16 Replacement Character |
|
||||
> | Standard Invalid Character | Potential UTF-16 Replacement Character |
|
||||
> |--------------------|------------------------------|
|
||||
> | . | ․ (One Dot Leader, `\u2024`) |
|
||||
> | : | ː (Modifier Letter Triangular Colon, `\u02D0`) |
|
||||
|
|
11
src/util.d
11
src/util.d
|
@ -350,9 +350,16 @@ bool isValidName(string path) {
|
|||
|
||||
// Regular expression for invalid patterns
|
||||
// https://support.microsoft.com/en-us/office/restrictions-and-limitations-in-onedrive-and-sharepoint-64883a5d-228e-48f5-b3d2-eb39e07630fa?ui=en-us&rs=en-us&ad=us#invalidcharacters
|
||||
// Leading whitespace and trailing whitespace/dot
|
||||
// Leading whitespace and trailing whitespace
|
||||
// Invalid characters
|
||||
auto invalidNameReg = ctRegex!(`^\s.*|^.*[\s\.]$|.*[<>:"\|\?*/\\].*`);
|
||||
// Trailing dot '.' (not documented above) , however see issue https://github.com/abraunegg/onedrive/issues/2678
|
||||
|
||||
//auto invalidNameReg = ctRegex!(`^\s.*|^.*[\s\.]$|.*[<>:"\|\?*/\\].*`); - original to remove at some point
|
||||
auto invalidNameReg = ctRegex!(`^\s+|\s$|\.$|[<>:"\|\?*/\\]`); // revised 25/3/2024
|
||||
// - ^\s+ matches one or more whitespace characters at the start of the string. The + ensures we match one or more whitespaces, making it more efficient than .* for detecting leading whitespaces.
|
||||
// - \s$ matches a whitespace character at the end of the string. This is more precise than [\s\.]$ because we'll handle the dot separately.
|
||||
// - \.$ specifically matches a dot character at the end of the string, addressing the requirement to catch trailing dots as invalid.
|
||||
// - [<>:"\|\?*/\\] matches any single instance of the specified invalid characters: ", *, :, <, >, ?, /, \, |
|
||||
|
||||
auto matchResult = match(itemName, invalidNameReg);
|
||||
if (!matchResult.empty) {
|
||||
|
|
Loading…
Reference in a new issue