]> git.ipfire.org Git - thirdparty/libarchive.git/commit
write_xar: move libxml2 behind an abstraction layer (#1849)
authorDustin L. Howett <dustin@howett.net>
Tue, 22 Oct 2024 09:10:50 +0000 (04:10 -0500)
committerGitHub <noreply@github.com>
Tue, 22 Oct 2024 09:10:50 +0000 (11:10 +0200)
commite619342dfa36b887ffa0ea33e98d04cb161cd7de
tree34f32c34b5ca6d9a4db8c1c13d2043b0bf6aefcd
parentae23713ceb5bb1c3c162c605a16aece8a8b1dcbc
write_xar: move libxml2 behind an abstraction layer (#1849)

This commit prepares the XAR writer for another XML writing backend.

Almost everything in this changeset leaves the code identical to how
it started, except for a new layer of indirection between the xar writer
and the XML writer.

The things that are not one-to-one renames include:
- The removal of `UTF8Toisolat1` for the purposes of validating UTF-8
- The writer code made a copy of every filename for the purposes of
  checking whether it was Latin-1 stored as UTF-8. In xar, Non-Latin-1
  gets stored Base64-encoded.
- I've replaced this use because (1) it was inefficient and (2)
  `UTF8Toisolat1` is a `libxml2` export.
- The new function has slightly different results than the one it is
  replacing for invalid UTF-8. Namely, it treats illegal UTF-8 "overlong"
  encodings of Latin-1 codepoints as _invalid_. It operates on the principle
  that we can determine whether something is Latin-1 based entirely on how
  long the sequence is expected to be.
- The move of `SetIndent` to before `StartDocument`, which the
  abstraction layer immediately undoes. This is to accommodate XML writers
  that require indent to be set _before_ the document starts.
libarchive/archive_write_set_format_xar.c
libarchive/test/test_write_format_xar.c