-
-
Notifications
You must be signed in to change notification settings - Fork 744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
text attributes: validate more strictly, fixes #2290 #7197
text attributes: validate more strictly, fixes #2290 #7197
Conversation
901a82e
to
e2be00d
Compare
Codecov Report
@@ Coverage Diff @@
## master #7197 +/- ##
==========================================
- Coverage 83.52% 83.50% -0.03%
==========================================
Files 67 67
Lines 11486 11540 +54
Branches 2078 2090 +12
==========================================
+ Hits 9594 9636 +42
- Misses 1343 1354 +11
- Partials 549 550 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
e2be00d
to
9001f26
Compare
we want to be able to use an archive name as a directory name, e.g. for the FUSE fs built by borg mount. thus we can not allow "/" in an archive name on linux. on windows, the rules are more restrictive, disallowing quite some more characters (':<>"|*?' plus some more). we do not have FUSE fs / borg mount on windows yet, but we better avoid any issues. we can not avoid ":" though, as our {now} placeholder generates ISO-8601 timestamps, including ":" chars. also, we do not want to have leading/trailing blanks in archive names, neither surrogate-escapes. control chars are disallowed also, including chr(0). we have python str here, thus chr(0) is not expected in there (is not used to terminate a string, like it is in C).
9001f26
to
ebff12a
Compare
MAX_PATH = 260 # Windows default. Since Win10, there is a registry setting LongPathsEnabled to get more. | ||
MAX_DIRNAME = MAX_PATH - len("12345678.123") | ||
SAFETY_MARGIN = 48 # borgfs path: mountpoint / archivename / dir / dir / ... / file | ||
MAX_ARCHIVENAME = MAX_DIRNAME - SAFETY_MARGIN | ||
if not (0 < len(text) <= MAX_ARCHIVENAME): | ||
raise argparse.ArgumentTypeError(f'Invalid archive name: "{text}" [0 < length <= {MAX_ARCHIVENAME}]') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we can not rely on LongPathsEnabled and we also need some (48) chars for the mountpoint and path components inside the archivename
directory, we are now down to 200 chars max for the archivename.
not needed any more as the comment is now validated pure text.
not needed any more as the archive name is now validated pure text.
this needs to get done differently later, maybe base64 for json output.
also: kill the
b*
(bpath, barchive, bcomment) stuff.