Skip to content

NonStrict flag for CPAN::Meta::YAML interop #44

@rurban

Description

@rurban

My plan is to use the best and fastest YAML module for YAML load and dump in core (as Cpanel::JSON::XS for json).
But LibYAML is too strict for the CPAN::Meta validation tests.
The root cause is that CPAN::Meta::YAML is broken, accepting too much illegal YAML.
I cannot load too many .yml files from CPAN prefs and build dirs.
So I am writing a NonStrict mode to workaround those quirks.

I'm ok with rejecting illegal structures, which would lead to
t/data-fixable/98042513-META.yml being not fixable but illegal.

    Class::Date:                   ^A^A^F

because the value for Class::Date is missing, and will not be assigned to undef (as CPAN::Meta::YAML, i.e. YAML::Tiny) does.

But this should be fixable with my new $NonStrict flag:

    Class::Date:                   0^A^A^F

The illegal control characters are ignored then.

$ cperl -MYAML::XS -e'$YAML::XS::NonStrict=0;$h=YAML::XS::LoadFile("t/data-fixable/98042513-META.yml"); print %$h'
YAML::XS::LoadFile Error: The problem

    control characters are not allowed

was found at document: 29, offset: 395
$ cperl -MYAML::XS -e'$YAML::XS::NonStrict=1;$h=YAML::XS::LoadFile("t/data-fixable/98042513-META.yml"); print %$h'
... (nyi)

The 2nd problem is an illegal utf8 codepoint conflicts with perl core.
There I'm not sure yet if its a libyaml bug or a CPAN::Meta bug or really an illegal utf8 codepoint:

YAML::XS::LoadFile Error: The problem

invalid trailing UTF-8 octet

was found at document: 25708, offset: 70

not ok 40 - t/data-test/unicode.yml validates
#   Failed test 't/data-test/unicode.yml validates'
#   at t/validator.t line 40.
# ERRORS:
# Missing mandatory field, 'version' (version) [Validation: 1.0]

Ok with this plan?

BTW: As you can see in the errmsgs I have already written a XS version for LoadFile,
which uses the better file iterator. Unfortunately I haven't yet wired the filename from XS down to libyaml, which only needs a FILE*. So the errmsg is not good enough yet. But still better than now. You'll see with my upcoming PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions