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

Xampp crashes on Develop when template has too many ORs in an IF statement

    Details

    • Type: Bug
    • Status: Unverified Fix
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 3.1.0-dev
    • Fix Version/s: 3.1.0-a1
    • Component/s: Template Engine
    • Labels:
      None
    • Environment:
      Tested on:
      Xampplite 1.7.7 on Windows 7 x86 SP1
      Xampplite 1.7.7 on Windows 7 x64 SP1

      Xampplite 1.7.7 includes:
      Apache 2.2.21, MySQL 5.5.16, PHP 5.3.8, phpMyAdmin 3.4.5, OpenSSL 1.0.0e

      Description

      I found a strange problem with the new template engine when your server is xampp.

      Steps to reproduce:

      1. Download xampp (or xampplite/USB) to your windows computer: http://www.apachefriends.org/de/xampp-windows.html#631
      2. Install phpBB from current develop branch on github: https://github.com/phpbb/phpbb3/downloads
      3. In viewtopic_body.html duplicate the ORs in the template IF by replace

        <!-- IF postrow.U_PM or postrow.U_EMAIL or postrow.U_WWW or postrow.U_MSN or postrow.U_ICQ or postrow.U_YIM or postrow.U_AIM or postrow.U_JABBER -->

        with

        <!-- IF postrow.U_PM or postrow.U_EMAIL or postrow.U_WWW or postrow.U_MSN or postrow.U_ICQ or postrow.U_YIM or postrow.U_AIM or postrow.U_JABBER or postrow.U_EMAIL or postrow.U_WWW or postrow.U_MSN or postrow.U_ICQ or postrow.U_YIM or postrow.U_AIM or postrow.U_JABBER -->

      4. Visit the viewtopic.php

      As a result your xampp crashes. (After investigation I found out, that it crashes after 8 ORs or more)

      NOTE: If you use the same modification (Step 3.) on develop-olympus it displayes the page just fine, which is the reason why I am reporting this!

      1. 3.1_vs_3.0_regex.diff
        7 kB
        Joas Schilling
      2. compare30to31.diff
        74 kB
        Joas Schilling
      3. test.diff
        12 kB
        Joas Schilling

        Activity

        Hide
        nickvergessen Joas Schilling added a comment - - edited

        I tracked it back, the commit which introduced the code is:
        https://github.com/phpbb/phpbb3/commit/2d11e1c095b7cf6197b7ce21bde806ad2cc178d8 "Improved Template Engine"

        I made a diff of the resulting index.php output with and without the line, see test.diff

        Show
        nickvergessen Joas Schilling added a comment - - edited I tracked it back, the commit which introduced the code is: https://github.com/phpbb/phpbb3/commit/2d11e1c095b7cf6197b7ce21bde806ad2cc178d8 "Improved Template Engine" I made a diff of the resulting index.php output with and without the line, see test.diff
        Hide
        nickvergessen Joas Schilling added a comment -

        There was a similar regex in 3.0 (thanks to A_Jelly_Donut):
        https://github.com/phpbb/phpbb3/commit/2d11e1c095b7cf6197b7ce21bde806ad2cc178d8#L0L259

        if i replace the new regex:

        $data = preg_replace('~(?<!^)(<\?php(?:(?<!\?>).)+(?<!/\*\*/)\?>)$~m', "$1\n", $data);

        with the old one:

        $data = preg_replace('#\?\>([\r\n])#', '?>\1\1', $data);

        You get 3.1_vs_3.0_regex.diff
        so there are just some newlines missing:

        [00:14:21] <APTX> the reason I added this was so that you won't get empty lines in the output for lines which only had a template stuff
        [00:15:02] <APTX> so a <!-- BEGIN foo --> on a line won't give you an empty line in the output, while a

        {VAR}

        still would
        [00:15:54] <APTX> this is because <!-- BEGIN foo --> doesn't produce any output, so you really get an empty line unintentionally when you put it on it's own line

        However, I would consider this "not worth it" (chance of crashing server against having some additional newlines)

        Show
        nickvergessen Joas Schilling added a comment - There was a similar regex in 3.0 (thanks to A_Jelly_Donut): https://github.com/phpbb/phpbb3/commit/2d11e1c095b7cf6197b7ce21bde806ad2cc178d8#L0L259 if i replace the new regex: $data = preg_replace('~(?<!^)(<\?php(?:(?<!\?>).)+(?<!/\*\*/)\?>)$~m', "$1\n", $data); with the old one: $data = preg_replace('#\?\>([\r\n])#', '?>\1\1', $data); You get 3.1_vs_3.0_regex.diff so there are just some newlines missing: [00:14:21] <APTX> the reason I added this was so that you won't get empty lines in the output for lines which only had a template stuff [00:15:02] <APTX> so a <!-- BEGIN foo --> on a line won't give you an empty line in the output, while a {VAR} still would [00:15:54] <APTX> this is because <!-- BEGIN foo --> doesn't produce any output, so you really get an empty line unintentionally when you put it on it's own line However, I would consider this "not worth it" (chance of crashing server against having some additional newlines)
        Hide
        nickvergessen Joas Schilling added a comment -

        Possible patch: https://github.com/nickvergessen/phpbb3/compare/phpbb:develop...nickvergessen:ticket/10876

        However this breaks 18 template tests (which compare the output and need to get some newlines added)

        Show
        nickvergessen Joas Schilling added a comment - Possible patch: https://github.com/nickvergessen/phpbb3/compare/phpbb:develop...nickvergessen:ticket/10876 However this breaks 18 template tests (which compare the output and need to get some newlines added)
        Hide
        nickvergessen Joas Schilling added a comment -

        The new version also matches our template tests

        Show
        nickvergessen Joas Schilling added a comment - The new version also matches our template tests
        Hide
        bantu Andreas Fischer added a comment -

        What is the cause of this problem? What is the difference between CLI config and webserver config?

        Show
        bantu Andreas Fischer added a comment - What is the cause of this problem? What is the difference between CLI config and webserver config?

          People

          • Assignee:
            nickvergessen Joas Schilling
            Reporter:
            nickvergessen Joas Schilling
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development