xoops forums

toolsmythe

Just popping in
Posted on: 2007/5/11 4:16
toolsmythe
toolsmythe (Show more)
Just popping in
Posts: 34
Since: 2004/11/27
#1

Site Name With Contraction Truncated in Email Form

This has been a bug in every version of XOOPS I've used.

If your site name has a single quote in it (i.e., John's XOOPS Site), the site name is truncated at the first occurence of the single quote on the mail form (so in the aforementioned example, the "From Name (email only)" field would read "John" and not "John's XOOPS Site").

I traced this problem to the render() function in /class/xoopsform/formtext.php. This function renders all the text boxes for the page and encloses the value parameter in - of course - single quotes. So, an embedded single quote causes a problem.

I tried the php urlencode() function, but render() is used for *ALL* the fields on the form so it was really mangeling things better left alone like email address. I finally decided that the best thing to do was just convert all single quotes to ' and not worry about anything else. Seems to work just fine, but I'd welcome a better solution if anyone else has one.

Here's the code out of the 2.0.16 codebase:

The file in question is /class/xoopsform/formtext.php. The problem is in the render() function .....

Original:

    function 
render(){
        return 
"<input type='text' name='".$this->getName()."' id='".$this->getName()."' size='".$this->getSize()."' maxlength='".$this->getMaxlength()."' value='".$this->getValue()."'".$this->getExtra()." />";
    }


My Hack:

    function 
render(){
// The following is a fix to resolve the issue that the site name was being truncated in forms if the site name contained a single quote.
// This was happening because the value parameter of the text box is enclosed in single quotes so any single quotes contained therein need to be
// replaced with their URL Encoded equivilant (single quote = &amp;#39;).  The original line is remains (commented out) for reference.
//        return "<input type='text' name='".$this->getName()."' id='".$this->getName()."' size='".$this->getSize()."' maxlength='".$this->getMaxlength()."' value='".$this->getValue()."'".$this->getExtra()." />";
        
return "<input type='text' name='".$this->getName()."' id='".$this->getName()."' size='".$this->getSize()."' maxlength='".$this->getMaxlength()."' value='".str_replace"'""&amp;#39;"$this->getValue() )."'".$this->getExtra()." />";
    }


JP

rowdie

Just can't stay away
Posted on: 2007/5/11 6:09
rowdie
rowdie (Show more)
Just can't stay away
Posts: 846
Since: 2004/7/21
#2

Re: Site Name With Contraction Truncated in Email Form

Try this:

function render(){
    return 
'<input type="text" name="'.$this->getName().'" id="'.$this->getName().'" size="'.$this->getSize().'" maxlength="'.$this->getMaxlength().'" value="'.$this->getValue().'"'.$this->getExtra().' />';
}


It's a short-term fix that is faster than using the str_replace() function in the render() method.

The real problem is with the mail users form. I'll post this issue to the sourceforge.net bug tracker for you, and attach a proper fix there when it's ready.

Thanks for reporting this

toolsmythe

Just popping in
Posted on: 2007/5/11 16:12
toolsmythe
toolsmythe (Show more)
Just popping in
Posts: 34
Since: 2004/11/27
#3

Re: Site Name With Contraction Truncated in Email Form

Rowdie -

Thanks for the response and the suggestion .

I considered your solution when I was looking at the issue. The problem I had with it is that it swaps one problem for another.

While it fixes "John's XOOPS Site", it now breaks "Murray "The K" Kaufman's XOOPS Site".

This is just a plain old limitation of HTML, and I don't see how it can be fixed save choosing if you are going to enclose values in single or double quotes and then doing a str_replace() for that character.

Thanks again, and thank you for escalating this; I didn't know where else to report it.

JP

toolsmythe

Just popping in
Posted on: 2007/5/12 0:29
toolsmythe
toolsmythe (Show more)
Just popping in
Posts: 34
Since: 2004/11/27
#4

Re: Site Name With Contraction Truncated in Email Form

Sorry, in my original post the HTML code for a single quote was being rendered into a single quote when I posted (so it looked like I was replacing "'" with "'" which, of course, makes no sense.

I've fixed it now.

JP