#986840 apt-listchanges fails to parse status files with ^M characters; should use apt_pkg.TagFile, not write its own parser

#986840#5
Date:
2021-04-12 18:14:07 UTC
From:
To:
As reported in https://bugs.launchpad.net/ubuntu/+source/apt-listchanges/+bug/1854772, apt-listchanges
fails to parse status files that contain carriage return characters, as
Python normalizes the line endings.

Instead of writing its own ad-hoc parser, apt-listchanges should use
apt_pkg.TagFile instead.

#986840#10
Date:
2021-04-12 18:53:09 UTC
From:
To:
Control: clone -1 -2
Control: reassign -2 dpkg
Control: retitle -2 dpkg: normalize description fields

I think it could be useful if dpkg could normalize description fields
too, to make the database safer to parse. I have not checked if the
output dpkg prints when reporting status is safe or not.

#986840#17
Date:
2021-07-01 15:48:50 UTC
From:
To:
I'm tracking the downstream bug in Ubuntu as well as this one.

I did a little bit of digging into how to rewrite the parser with your
suggested changes.  I agree that apt-listchanges should not be using its
own parser, especially since a standardized one exists in apt_pkg.

Preliminarily, I have these changes in mind for
apt_listchanges.ControlParser.readfile() (spacing adjusted for brevity):

```python
...
try:
  with apt_pkg.TagFile(file) as tagfile:
    for section in tagfile:
      self.stanzas += [ControlStanza(x) for x in section]
except: ...
```

There also, at the very least, may need a change to be made to
apt_listchanges.DebianFiles.ControlParser.readdeb() as well.  I'm hoping
that we can avoid rewriting some of the classes in
apt_listchanges.DebianFiles, namely ControlParser and ControlStanza.

If you have suggestions on how the change would look, please let me
know.

#986840#22
Date:
2021-07-01 15:57:10 UTC
From:
To:
Julian,

I didn't see that you cloned this bug and assigned it to dpkg and that
the bug is no longer in apt-listchanges.  I still think that your
original proposal for apt-listchanges is relevant and is a change worth
making.