I'm new on this site, hence a big Hello! to everyone
I am also new using php-nuke, which the CMS I've chossen for a website for a family member he has assigned me to create.
on a week of work with it, i've noticed some little issues, already explained around the world, as it's the issue(s) inserting html into content, the first bugfix from mine is about it...
...I think I've fixed, or better say, improved the delQuotes() function, unlike the original one, mine can handle attrib's values without being between quotes (which I needed so that Word documents saved as html can be easly inserted into content), and also it recognices ' delimiters, apart normal quotes.
let me know what you think, I hope my work is usefull for you/others and can be integreted into further php-nuke builds , the new function is as follow:
Code:
function delQuotes($string)
{
/* no recursive function to add quote to an HTML tag if needed */
/* and delete duplicate spaces between attribs. */
$tmp=""; # string buffer
$result=""; # result string
$i=0;
$attrib=-1; # Are us in an HTML attrib ? -1: no attrib 0: name of the attrib 1: value of the atrib
$quote=0; # Is a string quote delimited opened ? 0=no, 1=yes
# improved version by diegocr starts here: mine handles attrib's values
# without being between quotes, and using ' as well
# $Id: delQuotes.php,v 8.1.34.0.1 2008/02/06 20:37:16 diegocr Exp $
$apos=0; # means the same as for $quotes, but for '
$noquote=0; # handling attrib value without quotes?
$len = strlen($string);
while ($i<$len) {
switch($string[$i])
{
case "'":
if($quote==0 AND $noquote==0) { # do not handle if we are into normal quotes
if ($apos==0) {
$apos=1;
} else {
$apos=0;
if (($attrib>0) && ($tmp != "")) { $result .= "=\"$tmp\""; }
$tmp="";
$attrib=-1;
}
} else $tmp .= "'";
break;
case "\"":
if($apos==0 AND $noquote==0) { # do not handle if we are into single quote
if ($quote==0) {
$quote=1;
} else {
$quote=0;
if (($attrib>0) && ($tmp != "")) { $result .= "=\"$tmp\""; }
$tmp="";
$attrib=-1;
}
} else $tmp .= "\"";
break;
case "=":
if($quote==0 AND $apos==0) # do not handle if we are into any quotes
{
$attrib=1;
if ($tmp!="") $result.= " $tmp";
// FIXME: I assume there are no spaces between <attrib>=<value>
if(($string[$i+1] != "\"") AND ($string[$i+1] != "'"))
{
$noquote = 1;
}
$tmp="";
} else $tmp .= '=';
break;
case "\t":
case " ":
if($noquote==1) {
if($tmp != "")
$result .= "=\"$tmp\"";
$noquote=0;
$tmp="";
$attrib=-1;
}
else if($attrib>-1) { # add it to the string, if one opened.
$tmp .= $string[$i];
}
break;
default: # Other
if ($attrib<0) # If we weren't in an attrib, set attrib to 0
$attrib=0;
$tmp .= $string[$i];
break;
}
$i++;
}
if ((($quote!=0) OR ($apos!=0)) && ($tmp != "")) {
if ($attrib==1) {
$result .= "=";
}
/* If it is the value of an atrib, add the '=' */
$result .= "\"$tmp\""; /* Add quote if needed (the reason of the function ;-) */
}
return $result;
}
bugfixes for my function are as well welcome, and greatly appreciated
next, i dunno if that was already already, under modules/Forums/modcp.php at line 243 $module_name is being used incorrectly.
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