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

Prefix for template values to give back value URL encoded

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed (View Workflow)
    • Trivial
    • Resolution: Fixed
    • 3.0.11
    • 3.1.0-a1
    • Template Engine
    • None
    • PHP 5.3.8

    Description

      Right now we have in /includes/functions_template.php in function compile_var_tags() the ability to prefix a template variable with LA_ to mask/encode the output for a JavaScript string:

      		// Handle addslashed language variables prefixed with LA_
      		// If a template variable already exist, it will be used in favor of it...
      		if (strpos($text_blocks, '{LA_') !== false)
      		{
      			$text_blocks = preg_replace('#\{LA_([A-Z0-9\-_]+)\}#', "<?php echo ((isset(\$this->_rootref['LA_\\1'])) ? \$this->_rootref['LA_\\1'] : ((isset(\$this->_rootref['L_\\1'])) ? addslashes(\$this->_rootref['L_\\1']) : ((isset(\$user->lang['\\1'])) ? addslashes(\$user->lang['\\1']) : '{ \\1 }'))); ?>", $text_blocks);
      		}

      There should also be a prefix for URL encoding a value, so users don't have to modify PHP files when needing any value to be put into another URL.

      My suggestion:

      		// Handle URL encoded language variables prefixed with LU_
      		// If a template variable already exist, it will be used in favor of it...
      		if (strpos($text_blocks, '{LU_') !== false)
      		{
      			$text_blocks = preg_replace('#\{LU_([A-Z0-9\-_]+)\}#', "<?php echo ((isset(\$this->_rootref['LU_\\1'])) ? \$this->_rootref['LU_\\1'] : ((isset(\$this->_rootref['L_\\1'])) ? urlencode(\$this->_rootref['L_\\1']) : ((isset(\$user->lang['\\1'])) ? urlencode(\$user->lang['\\1']) : '{ \\1 }'))); ?>", $text_blocks);
      		}

      Inspired by https://www.phpbb.com/community/viewtopic.php?f=71&t=2165668

      Attachments

        Activity

          People

            EXreaction EXreaction [X] (Inactive)
            AmigoJack AmigoJack
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: