Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

YAML::XS perl/regexp (?u:(?u:

by Boldra (Deacon)
on Dec 05, 2017 at 10:41 UTC ( #1204940=perlquestion: print w/replies, xml ) Need Help??
Boldra has asked for the wisdom of the Perl Monks concerning the following question:

My YAML being read is
--- NODE: match: !!perl/regexp (?^ui:OK\ Server\ Connection\ 1\.001)
After loading/dumping it looks like this
--- NODE: match: !!perl/regexp (?^u:(?^ui:OK\ Server\ Connection\ 1\.001))
After 20 load/dump cycles it looks like this:
--- NODE: match: !!perl/regexp (?^u:(?^u:(?^u:(?^u:(?^u:(?^u:(?^u:(?^u:(?^u:(? +^u:(?^u:(?^u:(?^u:(?^u:(?^u:(?^u:(?^u:(?^u:(?^u:(?^u:(?^ui:OK\ Server\ Connection\ 1\.001)))))))))))))))))))))
My test:
perl -MYAML::XS -E 'my $y=YAML::XS::Load(q{---\nNODE:\n match: !!perl +/regexp (?i-xsm:OK\ Server\ Connection\ 1\.001)}); for(1..20) { $y=Lo +ad(Dump($y)) }; say Dump($y)'
$YAML::XS::VERSION = 0.66
perl v5.24.3

If I let it run long enough, eventually the parser breaks down. Does anyone have any suggestions?



- Boldra

Replies are listed 'Best First'.
Re: YAML::XS perl/regexp (?u:(?u:
by Boldra (Deacon) on Dec 05, 2017 at 12:49 UTC

      I’m sorry, Boldra, but I really do not understand your inspiration, even after reading the node that you referenced.   Would you please post another reply to this thread which summarizes what is the actual issue (and, solution) here?

      Many thanks in advance.

          A reply falls below the community's threshold of quality. You may see it by logging in.

        The "actual" issue is YAML::XS will not properly roundtrip regular expression serialization and deserialization. There is no solution—other than using a better-behaved YAML handler—until the package is patched against this bug.

Re: YAML::XS perl/regexp (?u:(?u:
by ikegami (Pope) on Dec 05, 2017 at 15:32 UTC

    YAML should store the pattern (( re::regexp_pattern($re) )[0]) and the modifiers (( re::regexp_pattern($re) )[1]) separately.

      YAML should store the pattern (( re::regexp_pattern($re) )[0] ) and the modifiers ( ( re::regexp_pattern($re) )[1] ) separately.

      ...and YAML::XS should make use of XS(XS_re_regexp_pattern) in universal.c to achieve that. Inevitably, this raises backcompat issues.

      perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

        and YAML::XS should make use of XS(XS_re_regexp_pattern) in universal.c

        And how does one do that? XS(XS_re_regexp_pattern) creates the Perl sub re::regexp_pattern, so that's a very weird way of saying that YAML::XS should call Perl sub re::regexp_pattern.

        Inevitably, this raises backcompat issues.

        This can be addressed by storing them as a different type than perl/regexp (perl/regexp_plus_mods?).

      It would be possible to store a regex as a sequence and use the same tag for it:
      --- re1: !!perl/regexp (?^usi:pattern) re2: !!perl/regexp [ pattern, isu ]
      For perl 5.8 the old behaviour could be used. This could be done for YAML and YAML::XS. Possibly also for YAML::Syck, which has the same problem, but I would have to ask Todd, the maintainer.

        You can add understanding of !!perl/regexp [ pattern, isu ] at any time, but backwards compatibility requires making the generation of that an option. Eventually, once support has been established, it could default to the new method.

Re: YAML::XS perl/regexp (?u:(?u:
by tinita (Parson) on Dec 08, 2017 at 17:05 UTC
Re: YAML::XS perl/regexp (?u:(?u:
by Anonymous Monk on Dec 05, 2017 at 10:49 UTC
      I think issue 64 is not related to this one

      Edit: I thought you meant "[already] Reported upstream"

        I think issue 64 is not related to this one

        good observation, hence recommend to report it :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1204940]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2018-10-16 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...














    Results (85 votes). Check out past polls.

    Notices?