Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-9296

^ and $ shouldn't match newlines in Pattern

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Won't Do
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Docs
    • Labels:
    • Template:
    • Team:
      Coremunity
    • QA Risk Assessment:
      Needs Assessment

      Description

      Pattern currently matches ^ and $ to newlines as well as start and end of string (multiline mode). It would be less surprising if they behaved like \A and \z (or maybe \Z).

      I've seen a number of places where people use the wrong anchors. The most obvious place is in stdlib, e.g. Stdlib::Unixpath.

      ❯ puppet apply -e 'notice("foo\nbar\nbah" =~ Pattern["^bar$"])'
      Notice: Scope(Class[main]): true
       
      ❯ puppet apply -e 'notice("foo\nbar\nbah" =~ Pattern["\\Abar\\z"])'
      Notice: Scope(Class[main]): false
       
      ❯ puppet apply -e 'notice("bar" =~ Pattern["\\Abar\\z"])' 
      Notice: Scope(Class[main]): true
      

      I've stripped out some lines to make this more legible.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              daniel.parks Daniel Parks
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Zendesk Support