LibraryOfCongress / bagit-python

Work with BagIt packages from Python.
http://libraryofcongress.github.io/bagit-python
218 stars 85 forks source link

values passed to command line options lose line breaks #126

Open t4k opened 5 years ago

t4k commented 5 years ago

I'm trying to pass a string with newlines into the command line option for filling the External-Description metadata element, formatted nicely in accordance with the spec (https://tools.ietf.org/html/rfc8493#section-2.2.2), but because of #19 back in 2014, these newlines are getting stripped out and I cannot have a nicely wrapped bag-info.txt file.

mhucka commented 5 years ago

It seems that the behavior of bagit.py is asymmetrical with respect to how it treats long tag lines: it handles folded lines when reading bag-info.txt, but it does not fold long lines when writing long tag values into bag-info.txt. This is hardwired into the function _make_tag_file(), which explicitly strips line endings from tag values before writing them (see line 1231).

mhucka commented 5 years ago

I just did a PR for changes that implement a new flag, --wrap. This change has been working for us in preliminary testing.