Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-11435

Extension template files curly braces bug

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • 3.1.0-a1
    • 3.1.0-dev
    • Extensions
    • None
    • PHP 5.3.6, phpBB 3.1-dev, Safari 6.0.2

      In an extension with template event files that use language vars, the language vars are injected with a newline immediately after each lang var.

      This breaks javascript when js code uses language vars in it's code, such as in strings. It can also potentially break html.

      Example: an extension template file (i.e.: overall_footer_after.html) contains:

      <script type="text/javascript">
       
      var text = "{LA_FORUM_INDEX}";
       
      </script>
       
      <div>{L_FORUM_INDEX}</div>
      

      This is rendered by phpBB in HTML as:

      <script type="text/javascript">
       
      var text = "Board index
      ";
       
      </script>
       
      <div>Board index
      </div>
      

      Note the new line added after the language var! This happens for both LA_ and L_ language vars anywhere they may be used in extension template files. It also does not matter if the extension's template is using core phpBB lang vars, and/or its own. It happens in all cases with extension templates.

      Update: This isn't limited to language vars. It's any where a curly brace variable is used in an event template file, i.e.:

      <a href="{U_VIEW_TOPIC}" class="topictitle">{TOPIC_TITLE}</a> 
      

      becomes:

      <a href="./viewtopic.php?f=2&amp;t=7
      " class="topictitle">My Great Topic
      </a>  
      

      or

      <dl class="icon {TOPIC_IMG_STYLE}">
      

      becomes:

      <dl class="icon topic_read
      ">
      

      Notice that every } closing curly brace creates a newline in the html output

      I also examined a cached file, to see how the php is being rendered by the template engine, and found the previous example to look something like this:

      <dl class="icon <?php echo (isset($_row_val['TOPIC_IMG_STYLE'])) ? $_row_val['TOPIC_IMG_STYLE'] : ''; ?>
       
      ">
      

      As you can see, actually two newlines are added between the closing php tag and the double quote from the template!

      So it is like the template engine is adding ?>\n\n for every closing curly brace.

            EXreaction EXreaction [X] (Inactive)
            VSE Matt Friedman [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: