Loading ...
Sorry, an error occurred while loading the content.

Patch 7.4.421

Expand Messages
  • Bram Moolenaar
    Patch 7.4.421 Problem: Crash when searching for ze* . (Urtica Dioica) Solution: Disallow a multi after ze and zs. Files: src/regexp_nfa.c,
    Message 1 of 5 , Aug 29, 2014
    • 0 Attachment
      Patch 7.4.421
      Problem: Crash when searching for "\ze*". (Urtica Dioica)
      Solution: Disallow a multi after \ze and \zs.
      Files: src/regexp_nfa.c, src/testdir/test64.in, src/testdir/test64.ok


      *** ../vim-7.4.420/src/regexp_nfa.c 2014-05-13 19:37:19.489786520 +0200
      --- src/regexp_nfa.c 2014-08-29 11:14:12.030416520 +0200
      ***************
      *** 291,296 ****
      --- 291,297 ----
      static int nfa_regconcat __ARGS((void));
      static int nfa_regbranch __ARGS((void));
      static int nfa_reg __ARGS((int paren));
      + static int re_mult_next __ARGS((char *what));
      #ifdef DEBUG
      static void nfa_set_code __ARGS((int c));
      static void nfa_postfix_dump __ARGS((char_u *expr, int retval));
      ***************
      *** 1323,1332 ****
      --- 1324,1337 ----
      {
      case 's':
      EMIT(NFA_ZSTART);
      + if (re_mult_next("\\zs") == FAIL)
      + return FAIL;
      break;
      case 'e':
      EMIT(NFA_ZEND);
      nfa_has_zend = TRUE;
      + if (re_mult_next("\\ze") == FAIL)
      + return FAIL;
      break;
      #ifdef FEAT_SYN_HL
      case '1':
      ***************
      *** 2276,2281 ****
      --- 2281,2298 ----
      return OK;
      }

      + /*
      + * Used in a place where no * or \+ can follow.
      + */
      + static int
      + re_mult_next(what)
      + char *what;
      + {
      + if (re_multi_type(peekchr()) == MULTI_MULT)
      + EMSG2_RET_FAIL(_("E888: (NFA regexp) cannot repeat %s"), what);
      + return OK;
      + }
      +
      #ifdef DEBUG
      static char_u code[50];

      *** ../vim-7.4.420/src/testdir/test64.in 2014-05-13 16:44:25.633695709 +0200
      --- src/testdir/test64.in 2014-08-29 11:33:12.330419011 +0200
      ***************
      *** 459,465 ****
      : let text = t[2]
      : let matchidx = 3
      : for engine in [0, 1, 2]
      ! : if engine == 2 && re == 0 || engine == 1 && re ==1
      : continue
      : endif
      : let ®expengine = engine
      --- 459,465 ----
      : let text = t[2]
      : let matchidx = 3
      : for engine in [0, 1, 2]
      ! : if engine == 2 && re == 0 || engine == 1 && re == 1
      : continue
      : endif
      : let ®expengine = engine
      ***************
      *** 608,613 ****
      --- 608,624 ----
      "ayb20gg/..\%$
      "bybGo "apo "bp:"
      :"
      + :" Check for detecting error
      + :set regexpengine=2
      + :for pat in [' \ze*', ' \zs*']
      + : try
      + : let l = matchlist('x x', pat)
      + : $put ='E888 NOT detected for ' . pat
      + : catch
      + : $put ='E888 detected for ' . pat
      + : endtry
      + :endfor
      + :"
      :""""" Write the results """""""""""""
      :/\%#=1^Results/,$wq! test.out
      ENDTEST
      *** ../vim-7.4.420/src/testdir/test64.ok 2014-05-13 16:44:25.633695709 +0200
      --- src/testdir/test64.ok 2014-08-29 11:36:05.782419390 +0200
      ***************
      *** 1097,1099 ****
      --- 1097,1101 ----
      Test END
      EN
      E
      + E888 detected for \ze*
      + E888 detected for \zs*
      *** ../vim-7.4.420/src/version.c 2014-08-29 10:04:32.226407390 +0200
      --- src/version.c 2014-08-29 11:37:15.794419543 +0200
      ***************
      *** 743,744 ****
      --- 743,746 ----
      { /* Add new patch number below this line */
      + /**/
      + 421,
      /**/

      --
      From "know your smileys":
      :----} You lie like Pinocchio

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ an exciting new programming language -- http://www.Zimbu.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --
      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/d/optout.
    • James McCoy
      ... This now behaves differently than the original regex engine. With set re=1 , / ze* matches every position. Should the behavior be unified, one way or
      Message 2 of 5 , Aug 29, 2014
      • 0 Attachment
        On Fri, Aug 29, 2014 at 11:58:09AM +0200, Bram Moolenaar wrote:
        >
        > Patch 7.4.421
        > Problem: Crash when searching for "\ze*". (Urtica Dioica)
        > Solution: Disallow a multi after \ze and \zs.

        This now behaves differently than the original regex engine. With
        "set re=1", /\ze* matches every position. Should the behavior be
        unified, one way or the other?

        Cheers,
        --
        James
        GPG Key: 4096R/331BA3DB 2011-12-05 James McCoy <jamessan@...>

        --
        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/d/optout.
      • Ben Fritz
        ... I m pretty sure ze* should be an invalid pattern, not match everything. -- -- You received this message from the vim_dev maillist. Do not top-post! Type
        Message 3 of 5 , Aug 29, 2014
        • 0 Attachment
          On Friday, August 29, 2014 8:12:34 PM UTC-5, James McCoy wrote:
          > On Fri, Aug 29, 2014 at 11:58:09AM +0200, Bram Moolenaar wrote:
          >
          > >
          >
          > > Patch 7.4.421
          >
          > > Problem: Crash when searching for "\ze*". (Urtica Dioica)
          >
          > > Solution: Disallow a multi after \ze and \zs.
          >
          >
          >
          > This now behaves differently than the original regex engine. With
          >
          > "set re=1", /\ze* matches every position. Should the behavior be
          >
          > unified, one way or the other?
          >
          >

          I'm pretty sure \ze* should be an invalid pattern, not match everything.

          --
          --
          You received this message from the "vim_dev" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/d/optout.
        • Bram Moolenaar
          ... Yes, that s what I thought. So we could also change the old engine. Anybody who would have a problem with that? Since it s a separate place in the code it
          Message 4 of 5 , Aug 30, 2014
          • 0 Attachment
            Ben Fritz wrote:

            > On Friday, August 29, 2014 8:12:34 PM UTC-5, James McCoy wrote:
            > > On Fri, Aug 29, 2014 at 11:58:09AM +0200, Bram Moolenaar wrote:
            > > >
            > > > Patch 7.4.421
            > > > Problem: Crash when searching for "\ze*". (Urtica Dioica)
            > > > Solution: Disallow a multi after \ze and \zs.
            > >
            > > This now behaves differently than the original regex engine. With
            > > "set re=1", /\ze* matches every position. Should the behavior be
            > > unified, one way or the other?
            >
            > I'm pretty sure \ze* should be an invalid pattern, not match everything.

            Yes, that's what I thought. So we could also change the old engine.
            Anybody who would have a problem with that?
            Since it's a separate place in the code it can be a separate patch.

            --
            From "know your smileys":
            (:-# Said something he shouldn't have

            /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
            /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
            \\\ an exciting new programming language -- http://www.Zimbu.org ///
            \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

            --
            --
            You received this message from the "vim_dev" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_dev" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
            For more options, visit https://groups.google.com/d/optout.
          • Ben Fritz
            ... Actually, when used as the only thing in the pattern, it should probably match a literal * character now that I think about it; because of this text in
            Message 5 of 5 , Aug 30, 2014
            • 0 Attachment
              On Saturday, August 30, 2014 11:10:49 AM UTC-5, Bram Moolenaar wrote:
              > Ben Fritz wrote:
              >
              >
              > > I'm pretty sure \ze* should be an invalid pattern, not match everything.
              >
              >
              >
              > Yes, that's what I thought. So we could also change the old engine.
              >
              > Anybody who would have a problem with that?
              >


              Actually, when used as the only thing in the pattern, it should probably match a literal '*' character now that I think about it; because of this text in :he /* :

              Exception: When "*" is used at the start of the pattern or just after
              "^" it matches the star character.

              --
              --
              You received this message from the "vim_dev" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php

              ---
              You received this message because you are subscribed to the Google Groups "vim_dev" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
              For more options, visit https://groups.google.com/d/optout.
            Your message has been successfully submitted and would be delivered to recipients shortly.