[Toybox] [PATCH v2]diff and patch: support special characters in filenames with quoting as well as unusual timestamp formats
William Haddon
william at haddonthethird.net
Thu Aug 29 11:04:19 PDT 2019
After further research and testing, I've produced a patch which handles
all filenames with special characters by copying the GNU quoting
behavior, and also treats anything following a tab as a timestamp. This
increases both ability to handle possible filenames and ability to
apply patches found in the field.
Specifically, diff quotes and escapes filenames according to the
following rules.
* Surround the filename with quotes if it contains a byte less than
0x20, a byte greater than or equal to 0x80, space, backslash, or quote.
* Replace alert, backspace, form feed, newline, carriage return, tab,
vertical tab, backslash, and quote with \a, \b, \f, \n, \r, \t, \v, \\,
and \", respectively.
* Replace other bytes less than 0x20 or greater than or equal to 0x80
with a backslash followed by the three octal digits representing the
value of the byte.
* Treat valid UTF-8 characters involving sequences of bytes greater
than or equal to 0x80 the same as other sequences of such bytes.
patch processes quoted and escaped filenames according to the following
rules.
* If the filename does not begin with a quote, do not modify the
filename.
* Remove quotes surrounding the filename.
* In quoted filenames, replace \a, \b, \f, \n, \r, \t, \v, \\, and \"
with alert, backspace, form feed, newline, carriage return, tab,
vertical tab, backslash, and quote, respectively.
* In quoted filenames, replace a backslash followed by octal digits
with the byte with that value in octal.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: toybox-patch-special-characters.patch
Type: text/x-patch
Size: 4842 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20190829/ba00e882/attachment.bin>
More information about the Toybox
mailing list