Forums Sign Up Reply Search Statistics
Fast Template GraFX Software Solutions - Forum / Fast Template /

Fast Template Bug with quotes in JS

 
rr1024
Forums Member
#1 Posted: 19 Jul 2008 16:10:47
Reply 
Hello, I think I found a bug in Fast Template
My html or template has the following onclick event for a given URL

onclick="if( el.style.display == 'none' ){ el.style.display = 'block'; this.src = '{TPL_IMAGES}arr_dn_act.gif'; } else { el.style.display = 'none'; this.src = '{TPL_IMAGES}arr_dn.gif'; }"

However, after parsing the template the JS code has been change from the above to the following

onclick="if( el.style.display == 'none' ){ el.style.display = 'block'; this.src="http://localhost/dev/template_dev/templa tes/tpl_default/adm/images/arr_dn_act.gif"; } else { el.style.display = 'none'; this.src="http://localhost/dev/template_dev/templa tes/tpl_default/adm/images/arr_dn.gif"; }"

The problem is Fast Template has changed my single quote to double quotes for the replaced URL's

'{TPL_IMAGES}arr_dn_act.gif' now = "http://localhost/dev/template_dev/templates/tpl_d efault/adm/images/arr_dn_act.gif"

Is there any fixes for this, is it a known bug?
rr1024
Forums Member
#2 Posted: 19 Jul 2008 16:36:35
Reply 
This seems to fix the issue

FUNCTION rewrite_src_path( $contents )
{
#Rewrite src path regex using Heredoc
$regexPattern[] = "/src\s*=(.*?)[\\\"']?([^\\\"' >]+)[\\\"'> ]/is";
//$regexPattern[] = "/<\s*link\s+[^>]*href\s*=\s*[\\\"']?([^\\\"' >]+)[\\\"' >]/is"; //BUG in 1.5.1
$regexPattern[] = "/<\s*link\s+[^>]*href\s*=\s*[\\\"']?[^\\\"' >]+[\\\"' >]/is";

IF ( sizeof( $this->REWRITE_SRC_PATH ) > 0 ) {
IF( strpos($contents, "'") ){
$contents=preg_replace($regexPattern[0], 'src=\''.$this->REWRITE_SRC_PATH.'\\2\'', $contents);
}ELSE{
$contents=preg_replace($regexPattern[0], 'src="'.$this->REWRITE_SRC_PATH.'\\2"', $contents);
}
// preg_reclace_callback RETURN his result to a FUNCTION outside class body
$GLOBALS['REWRITE_SRC_PATH'] = $this->REWRITE_SRC_PATH;
$contents=preg_replace_callback($regexPattern[1], 'rewrite_link_href_callback', $contents);
unset($GLOBALS['REWRITE_SRC_PATH']);
}

RETURN $contents;
}
software
Admin
#3 Posted: 21 Jul 2008 01:40:52
Reply 
We fixed locally, also modified to be enabled or disable REWRITE_SRC_PATH.
We will post new version asap.
rr1024
Forums Member
#4 Posted: 21 Jul 2008 20:19:57
Reply 
What does REWRITE_SRC_PATH do, I haven't had time to look at it but I was wondering what it was suppose to do
software
Admin
#5 Posted: 29 Jul 2008 09:58:14
Reply 
REWRITE_SRC_PATH is the base_url which should be added before the image paths.
 
Your reply
Bold Style  Italic Style  Image Link  URL Link 

» Username  » Password 
Only registered users are allowed to post here. Please enter your login/password details upon posting a message, or sign up first.