Skip to content
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

Detect and report incorrectly delimited strings #161

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Nov 13, 2024

  1. Detect and report incorrectly delimited strings

    Strings in pofiles are always delimited on both ends with double-quotes.
    The POFile parser in polib didn't check for this, and therefore happily
    accepted invalid msgstr/msgid/etc, potentially loosing some of the
    contents of the file. In such cases, the first or last character of the
    string would be lost, as *they* would be considered the string delimiters.
    
    This commit adds a check to the POFile parser to ensure strings are
    always delimited by double quotes on both ends. After adding it, I
    spotted a couple of offending po file contents in the tests, which have
    also been fixed. Additionally, a new test had been added to ensure these
    cases are caught. The new test indeed fails if the new check is removed.
    
    This issue was found while investigating an error produced by the
    "powrap" tool while running it over the po files for the Spanish
    translation of the CPython documentation. The tool failed check one of
    our files because gettext's `msgcat` utility failed to parse the file.
    Upon closer inspection I realised the error in our pofile, which was
    caught by gettext but not polib.
    
    Signed-off-by: Rodrigo Tobar <[email protected]>
    rtobar committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    9c760ba View commit details
    Browse the repository at this point in the history