Menu

#92 Error: now disappears $xx and \$xx

7.4pre1
closed-invalid
Template (13)
1
2002-08-10
2002-07-05
No

Hi, I was looking for a correction to the disappearing $,
then I tried this version of templates.inc

But I found two errors:
- templates.inc->set_var still eats "$xx", where x is a
literal
- templates.inc->set_var eats the \ in "\$xx"

if you do the following:
$t->set_var(array( "t1" => " $es ", "t2" => "
\$123 " ));
the variables inside the template object will became:
t1="" and t2="$123".
t1 is clearly wrong.
t2 seems wrong too (I don't know the inner
representation). After doing a $t->parse and a $t->p, in
place of {t2} you will get a "$123" which is wrong.

Discussion

  • Layne Weathers

    Layne Weathers - 2002-07-05

    Logged In: YES
    user_id=278685

    t1 depends completely on your setting of the PHP variable
    $es - you should be testing against ' $es ' so that PHP is not
    doing variable substitution within the string.

     
  • Richard Archer

    Richard Archer - 2002-07-05

    Logged In: YES
    user_id=279311

    I am confident that the current CVS version of template.inc
    behaves correctly in both these situations. Your second test
    result containing a "$" suggests to me that you're
    running an old version of template.inc. That kludge was
    removed from the script in April.

    The last change I made to resolve this issue was to run all
    variable values through preg_replace prior to substitution.
    While this incurs a performance hit over the previous
    kludges, it's practically guaranteed to result in the
    correct behaviour.

    I have attached my test script and template for this
    problem. The output consists of all template.inc's debugging
    output followed by a table of three columns. The first
    column is a description of the test, the second is the
    intended result as plain text and the third is the result
    after running through template.

    ...R.

     
  • Richard Archer

    Richard Archer - 2002-07-05

    special char test for template.inc

     
  • Joe Winter

    Joe Winter - 2002-07-10

    Logged In: YES
    user_id=206472

    I second layne weathers on this.

    Also add ${noTDTags} to your testspecialchars.tpl where
    there is no space, no td tags, nothing, between the $ sign
    and the curly brace.

     
  • Richard Archer

    Richard Archer - 2002-07-11

    Logged In: YES
    user_id=279311

    I tested this, and it works fine for me.

    Test files attached...

     
  • Richard Archer

    Richard Archer - 2002-07-11
    • assigned_to: nobody --> richardarcher
     
  • Richard Archer

    Richard Archer - 2002-07-11

    updated test for special chars

     
  • Nobody/Anonymous

    Logged In: NO

    you must use \\\$123

     
  • Richard Archer

    Richard Archer - 2002-08-01

    Logged In: YES
    user_id=279311

    Please post some code as an attachment which demonstrates
    this problem. So SF doesn't escape the sequence which causes
    the problem. Also, please include your copy of template.inc
    in the attachment.

    I still believe you're running a non-current version of
    template.inc. The logic in the current version seems to me
    to be unflawed.

    ...R.

     
  • Richard Archer

    Richard Archer - 2002-08-10
    • priority: 5 --> 1
    • status: open --> closed-invalid
     
  • Richard Archer

    Richard Archer - 2002-08-10

    Logged In: YES
    user_id=279311

    I'm closing this bug. I can't see any way the current logic
    in template.inc can be fooled into breaking in this way.

    I'm happy to look at any further reports of strange
    behaviour. Preferably accompanied by a test script and
    template which demonstrates the incorrect behaviour. Please
    attach a file to the bug report containing:
    a PHP script
    a template file
    your version of template.inc
    sample output
    a mock up of *correct* output

    Thank you!

    ...R.

     

Log in to post a comment.