Fix a bug in view filename generation when a metadata value ended with "/"

Or ":" or "\" on Windows, eg "c:" again.
This commit is contained in:
Joey Hess 2021-01-22 14:05:14 -04:00
parent e2ba8ae4a6
commit 5c7e6629cf
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 22 additions and 1 deletions

View file

@ -253,7 +253,8 @@ toViewPath = escapepseudo [] . decodeBS . fromMetaValue
| [c1,c2,c3] == pseudoBackslash = escapepseudo ("%":pseudoBackslash:s) cs
| [c1,c2,c3] == pseudoColon = escapepseudo ("%":pseudoColon:s) cs
| otherwise = escapepseudo ([c1]:s) (c2:c3:cs)
escapepseudo s cs = concat (reverse (cs:s))
escapepseudo s (c:cs) = escapepseudo ([c]:s) cs
escapepseudo s [] = concat (reverse s)
fromViewPath :: FilePath -> MetaValue
fromViewPath = toMetaValue . encodeBS . deescapepseudo []

View file

@ -34,6 +34,8 @@ git-annex (8.20201130) UNRELEASED; urgency=medium
overhead when inodes of files have changed, as happens whenever a FAT
filesystem gets remounted.
* Fix a bug that prevented git-annex init from working in a submodule.
* Fix a bug in view filename generation when a metadata value ended with
"/" (or ":" or "\" on Windows)
-- Joey Hess <id@joeyh.name> Mon, 04 Jan 2021 12:52:41 -0400

View file

@ -0,0 +1,18 @@
[[!comment format=mdwn
username="joey"
subject="""comment 4"""
date="2021-01-22T16:59:55Z"
content="""
Not sure if this is really the same bug, though certainly related. These
quickcheck tests are fuzz tests, they can find numerous bugs, that's kind of
the point of them. In any case, posting to a closed bug report risks your
followup being lost and deprioritises it.
The problem this new failure shows is that toViewPath is failing to escape the
final character in the path in some cases. Which is not a windows-specific
bug at all really, it could also happen with a metadata value such as "foo/"
being set on linux. Fixed that bug.
Which shows the point of these quickcheck fuzz tests: To be able to catch
lots of different bugs with a single test case.
"""]]