1
toolsmythe
Site Name With Contraction Truncated in Email Form
  • 2007/5/11 4:16

  • toolsmythe

  • Just popping in

  • Posts: 34

  • Since: 2004/11/27


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 
".$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 = ').  The original line is remains (commented out) for reference.
//        return "getName()."' id='".$this->getName()."' size='".$this->getSize()."' maxlength='".$this->getMaxlength()."' value='".$this->getValue()."'".$this->getExtra()." />";
        
return ".$this->getName()."' id='".$this->getName()."' size='".$this->getSize()."' maxlength='".$this->getMaxlength()."' value='".str_replace"'""'"$this->getValue() )."'".$this->getExtra()." />";
    }


JP

2
rowdie
Re: Site Name With Contraction Truncated in Email Form
  • 2007/5/11 6:09

  • rowdie

  • Just can't stay away

  • Posts: 846

  • Since: 2004/7/21


Try this:

function render(){
    return 
'.$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

3
toolsmythe
Re: Site Name With Contraction Truncated in Email Form
  • 2007/5/11 16:12

  • toolsmythe

  • Just popping in

  • Posts: 34

  • Since: 2004/11/27


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

4
toolsmythe
Re: Site Name With Contraction Truncated in Email Form
  • 2007/5/12 0:29

  • toolsmythe

  • Just popping in

  • Posts: 34

  • Since: 2004/11/27


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

Login

Who's Online

155 user(s) are online (99 user(s) are browsing Support Forums)


Members: 0


Guests: 155


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits