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

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


    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0.11
    • Fix Version/s: 3.2.0
    • Component/s: Posting
    • Labels:
    • Environment:
      PHP 5.3.8 with PCRE 8.12 2011-01-15


      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:


      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:


      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


          Issue Links



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


                • Created: