Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-11153

Custom BBCode token {EMAIL} subpattern are captured - token can never be used as parameter

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 3.0.11
    • 3.2.0
    • Posting
    • None
    • PHP 5.3.8 with PCRE 8.12 2011-01-15

    Description

      The regexp for validating an e-mail address is defined in /includes/functions.php, function get_preg_expression($mode):

      // Regex written by James Watts and Francisco Jose Martin Moreno
      // http://fightingforalostcause.net/misc/2006/compare-email-regex.php
      return '([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*(?:[\w\!\#$\%\'\*\+\-\/\=\?\^\`{\|\}\~]|&)+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,63})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)';

      This works as intended and using it in the native BBCode works flawless - e-mail addresses are recognized, hence the BBCode is accepted:

      [email=user@host.com]title[/email]
      [email]user@host.com[/email]

      When defining a custom BBCode you also have the option to use EMAIL as a token. However, you're unable to imitate the native e-mail BBCode which accepts the address as a parameter. As example: defining this will work, but using that BBCode in your posts will never be recognized/accepted:

      [myemail={EMAIL}]{TEXT}[/myemail]

      The reason for this is that the regexp for the e-mail address captures the subpatterns. After defining every subpattern to not be captured and re-submitting my custom BBCode in the ACP again (thus updating the database rowset) my very own BBCode also works like the native EMAIL BBcode with a parameter.

      The correct regexp:

      return '(?:[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*(?:[\w\!\#$\%\'\*\+\-\/\=\?\^\`{\|\}\~]|&)+@(?:(?:(?:(?:(?:[a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,63})|(?:\d{1,3}\.){3}\d{1,3}(?:\:\d{1,5})?)';

      Found while analyzing https://www.phpbb.com/community/viewtopic.php?f=71&t=2164409

      Attachments

        Issue Links

          Activity

            People

              CHItA CHItA
              AmigoJack AmigoJack
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: