-
Notifications
You must be signed in to change notification settings - Fork 442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List index out of range error in PoFileParser._add_message #1134
Comments
Here's a smaller reproducer: import io
from babel.messages.pofile import read_po
po = io.StringIO('msgid ""')
read_po(po) Neither is a valid PO file so we should ideally raise a |
Hey Tomas! Thanks for the response. I don't have a deep understanding of the way the PO files should be processed so a full PR may be challenging, but if I'm able to get some time I'll certainly check it out :) |
I think checking if |
Sounds good, thanks! Should the process exit when this is detected or should we only raise the warning and leave the exception raising up to the value of self.abort_invalid. |
Right, there's this |
Is the invariant here that if the messages list has an element in it, the translations list should also be populated? Adding in this check at the beginning of |
To be honest, I'm not that familiar with the parser code either, but I think you are right. We should only raise/warn when we call def _finish_current_message(self) -> None:
if self.messages:
if not self.translations:
# Handle error here
self._add_message() |
Yea that's what I was thinking as well :). I'll do some testing on it. |
The below code triggers a list index out of range error when provided a malformed input. This occurs in _add_message at line 235 in babel/messages/pofile.py.
Version
babel version 2.16.0
POC File
https:/FuturesLab/POC/blob/main/babel/poc-01
How to trigger:
python filename.py poc-01
Trace report
The text was updated successfully, but these errors were encountered: