Skip to content

mtree: escape METALOG filenames according to FreeBSD's mtree(8) / VIS_OCTAL#513

Open
tmarkettos wants to merge 2 commits into
mainfrom
tmarkettos-mtree-fix
Open

mtree: escape METALOG filenames according to FreeBSD's mtree(8) / VIS_OCTAL#513
tmarkettos wants to merge 2 commits into
mainfrom
tmarkettos-mtree-fix

Conversation

@tmarkettos

Copy link
Copy Markdown
Contributor

FreeBSD's mtree file format by default uses the VIS_OCTAL format of
strsvis(3) to escape non-printable characters in filenames, namely
anything not within chars 33-126 or shell globs. Attempt to handle
non-printable characters, including UTF-8, with an escaping function.
Some basic tests are included.

(A comment indicated that the VIS_CSTYLE format should be used, which
encodes whitespace as \t, \n and \s. According to the FreeBSD
mtree(8) manpage, that is only correct when using the 'netbsd6'
flavour of mtree output. Debian's mtree(5) also specifies the
VIS_OCTAL format)

FreeBSD's mtree file format by default uses the VIS_OCTAL format of
strsvis(3) to escape non-printable characters in filenames, namely
anything not within chars 33-126 or shell globs. Attempt to handle
non-printable characters, including UTF-8, with an escaping function.
Some basic tests are included.

(A comment indicated that the VIS_CSTYLE format should be used, which
encodes whitespace as \t, \n and \s. According to the FreeBSD
mtree(8) manpage, that is only correct when using the 'netbsd6'
flavour of mtree output. Debian's mtree(5) also specifies the
VIS_OCTAL format)
Comment thread pycheribuild/mtree.py
# split string into Unicode code points
c = ord(s[i])

# if a non-ASCII character, convert to 3 digit octal without the 0o prefix

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# if a non-ASCII character, convert to 3 digit octal without the 0o prefix
# if a non-ASCII or glob character, convert to 3 digit octal without the 0o prefix

I guess we are also escaping glob/shell special chars?

Comment thread pycheribuild/mtree.py
# append an ASCII character
s_dest += s[i]

# return s.upper().replace(" ", "\\s")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# return s.upper().replace(" ", "\\s")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants