YAML filter skips single quote at beginning of string

Issue #555 resolved
Nikolai Vladimirov created an issue

Hey,

Given the following YAML file:

test: "'s house"

The filter produces

<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:okp="okapi-framework:xliff-extensions" xmlns:its="http://www.w3.org/2005/11/its" xmlns:itsxlf="http://www.w3.org/ns/its-xliff/" its:version="2.0">
<file original="yml/example_single_quote.yml" source-language="en-us" target-language="fr-fr" datatype="x-text/x-yaml">
<body>
<group id="sg1">
<trans-unit id="tu1" resname="test" xml:space="preserve">
<source xml:lang="en-us">s house</source>
<target xml:lang="fr-fr">s house</target>
</trans-unit>
</group>
</body>
</file>
</xliff>

This looks like a valid YAML and the beginning single quote should be preserved.

Comments (4)

  1. Chase Tingley

    Changing it to only trim one leading quote works for this case, but it doesn't handle true nested quotes like this:

    test: "'hello'"
    

    The expected value, I think should be 'hello', but even with the simple fix, it comes out as hello.

    The parser combines a lot of the quote handling cases, and I think they may need to be pulled apart and handled separately in order to deal with all the cases here correctly.

  2. Jim Hargrave (OLD)

    One issue is that we use snakeyaml to do decoding of the strings once the original quotes are trimmed. But snakeyaml needs to now the original context to do this correctly. Using snakeyaml was a quick workaround and we really need to implement our own decoder/encoder to have more control.

    Also as Chase mentioned the QuotedScala needs to be updated to remove only the first quotes it finds.

  3. Jim Hargrave

    Latest M31 dev branch has fix

    Initial quotes now removed correctly and embedded leading single quotes not removed.

  4. Log in to comment