codegooglecom / querytemplates

Automatically exported from code.google.com/p/querytemplates
0 stars 0 forks source link

Bug in varPrintAttr() #30

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem? Example:

1. $template->varPrintAttr('href', 'row.name')
2. Results in compiled code:
a) PHP: ... <a href="" class="name" row.name="<?php  if
(isset($row['name'])) print $row['name'];
else if (isset($row->{'name'})) print $row->{'name'};  ?>"> ...
b) JavaScript: ... <a href="" class="name" row.name="';
19
20 print(row['name']);
21;
22 __template += '"> ...

It seems that the documentation says, that
1) the first arg is the attribute's name,
2) and the second arg is the var name

Original issue reported on code.google.com by test9...@gmx.de on 28 Dec 2009 at 1:50

GoogleCodeExporter commented 9 years ago
Edit: Should be high priority.

Original comment by test9...@gmx.de on 28 Dec 2009 at 1:56

GoogleCodeExporter commented 9 years ago
Can be partially solved by replacing line 450 in QueryTemplatesSyntaxVars.php 
by:

return $this->_varPrint(array('attr', $attr), $varName);

But there is still an issue, when I replace an a's href attribute - resulting 
code:

...<a href="<?php  if (isset($row['name'])) print $row['name'];%0Aelse if
(isset($row->{'name'})) print $row->{'name'};  ?>" class="name">...

Original comment by test9...@gmx.de on 28 Dec 2009 at 4:33

GoogleCodeExporter commented 9 years ago
@andreas. your fix is right. the %0A thing is an urlencoded newline

change: QueryTemplatesLanguagePHP.php line 15. remove the newline in generated 
output

it's still just a workaround, since the generated line should read something 
like this:

href="<?php if (isset($row['name'])) print urlencode($row['name']); else if
(isset($row->{'name'})) print urlencode($row->{'name'});  ?>"

Original comment by robbie.w...@gmail.com on 17 Sep 2010 at 2:41

GoogleCodeExporter commented 9 years ago
äh wrong, sorry. attribute values should not be escaped with 'urlencode()' but 
of course with 'htmlspecialchars()'

Original comment by robbie.w...@gmail.com on 24 Sep 2010 at 5:06