Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

some basic fixes or improvements of basic plug ins

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
shuther
Smarty Rookie


Joined: 04 Jan 2004
Posts: 13

PostPosted: Thu Feb 05, 2004 11:46 am    Post subject: some basic fixes or improvements of basic plug ins Reply with quote

Here is a list of some patches, I hope you will like them

in smarty\libs\plugins\function.mailto.php:
The variable $js_encode is never defined (there is a $js_encore =. after)
Quote:

diff -w -b -r1.7 function.mailto.php
102a103
> $js_encode = '';


----
We add a function, even if it is not mathematical, it ('count') is used often in computation (width of a column, ...)
Quote:

diff -w -b -r1.7 function.math.php
39c39
< $allowed_funcs = array('int','abs','ceil','cos','exp','floor','log','log10',
---
> $allowed_funcs = array('int','abs','ceil','cont', 'cos','exp','floor','log','log10',


-----
3 issues here:
- if a variable contains itself, the loop doesn't stop
- ressources are not handled correctly
- I think htmlentities should be used, instead of htmlspecialchars

The patch could be improved, but ...
Quote:

RCS file: /repository/smarty/libs/plugins/modifier.debug_print_var.php,v
retrieving revision 1.11
diff -w -b -r1.11 modifier.debug_print_var.php
23a24,34
> //Limit the number of elements shown
> static $_count = 1, $_countOver = 0;
>
> //The 500 could be a constant, or a variable defined in the $smarty class also...
> if ($_count > 500 || $depth > 4) {
> $_countOver++;
> return;
> }
>
> $_count++;
>
30a42
> return $results;
38,41c50
< } else if (is_resource($var)) {
< $results = '<i>'.(string)$var.'</i>';
< } else if (empty($var) && $var != "0") {
< $results = '<i>empty</i>';
---
> return $results;
42a52,62
> if (empty($var) && $var != "0") {
> return '<i>empty</i>';
> }
>
> if (is_numeric($var))
> return $var;
>
> if (!is_string($var)) {
> return gettype($var);
> }
>
48c68,70
< $results = htmlspecialchars($results);
---
> if (is_string($results))
> $results = htmlentities($results);
>
50d71
< }
52a74
> }


------
I think the use of empty is more correct, because some values are not catched with ===
Quote:

RCS file: /repository/smarty/libs/plugins/modifier.default.php,v
retrieving revision 1.4
diff -w -b -r1.4 modifier.default.php
23c23
< if (!isset($string) || $string === '')
---
> if (!isset($string) || empty($string))
25c25
< else
---
> else {
27a28
> }
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Feb 05, 2004 12:09 pm    Post subject: Re: some basic fixes or improvements of basic plug ins Reply with quote

shuther wrote:
I think the use of empty is more correct, because some values are not catched with ===
Quote:

RCS file: /repository/smarty/libs/plugins/modifier.default.php,v
retrieving revision 1.4
diff -w -b -r1.4 modifier.default.php
23c23
< if (!isset($string) || $string === '')
---
> if (!isset($string) || empty($string))
25c25
< else
---
> else {
27a28
> }


i think not. "0" may be empty in a php way-of-thinking. but it's not empty in a display way-of-thinking: it's one character long.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Feb 05, 2004 12:27 pm    Post subject: Re: some basic fixes or improvements of basic plug ins Reply with quote

shuther wrote:
Here is a list of some patches, I hope you will like them

in smarty\libs\plugins\function.mailto.php:
The variable $js_encode is never defined (there is a $js_encore =. after)
Quote:

diff -w -b -r1.7 function.mailto.php
102a103
> $js_encode = '';



right. i'll add that.

(debug_print_var:)
Quote:

3 issues here:
- if a variable contains itself, the loop doesn't stop
sure.

- ressources are not handled correctly
what's wrong with them?

- I think htmlentities should be used, instead of htmlspecialchars
why?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP