#986840 apt-listchanges fails to parse status files with ^M characters; should use apt_pkg.TagFile, not write its own parser #986840
- Package:
- apt-listchanges
- Source:
- apt-listchanges
- Submitter:
- Julian Andres Klode
- Date:
- 2021-07-01 16:00:02 UTC
- Severity:
- normal
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.
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.
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.
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.