Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: Making $ Unicode-aware

by jcb (Parson)
on Jul 28, 2020 at 01:38 UTC ( [id://11119874]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Making $ Unicode-aware
in thread Making $ Unicode-aware

Is that really intended to only match CRLF or should it be (?>\x0D?\x0A|\v) to also match traditional *nix line endings? (There is still a problem with (?>\x0D?\x0A|\v) — it does not match the traditional CR-only Macintosh line ending.) Why is vertical tab included?

Replies are listed 'Best First'.
Re^4: Making $ Unicode-aware
by jo37 (Deacon) on Jul 28, 2020 at 06:05 UTC

    \v is not the vertical tab. It matches the character class of "vertical whitespace". The characters belonging to this class are listed in perlrecharclass as:

    LINE FEED LINE TABULATION FORM FEED CARRIAGE RETURN NEXT LINE LINE SEPARATOR PARAGRAPH SEPARATOR
    So actually \R matches all single vertical space characters and the two character sequence CR LF. This includes all common line endings.

    Greetings,
    -jo

    $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$

      So \v is a regex class instead of a character escape. That makes sense, then.

      What existing code could changing $ to use \R instead of \n potentially break? Could this raise security issues by widening input validation patterns?

        What existing code could changing $ to use \R instead of \n potentially break? Could this raise security issues by widening input validation patterns?

        A bit difficult to say, as even \n is not just a LF but a "logical newline", as described in perlrebackslash:

        \n matches a logical newline. Perl converts between \n and your OS's native newline character when reading from or writing to text files.
        And because it is so hard to tell I wouldn't want to change the meaning of $ without explicit request to do so for a single regex or within a lexical scope, i.e. by a flag or pragma.

        Greetings,
        -jo

        $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11119874]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 16:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found