1
Peekay
Escape ampersands in News title?
  • 2008/5/4 10:06

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


I have noticed that although ampersands are converted to their html entity for article body text, it is not the case with title fields.

Is there a way I can fix it so that html entities are used in other fields that display on the page?

For example, in 'News' (1.53) I found the title field code:

$sform->addElement(new XoopsFormText(_NW_TITLE'title'50255$title), true);


This appears to use a class (XoopsFormText) in class/xoopsform/formtext.php. Should I be looking to alter this class in some way, or am I on the wrong route completely?

Any guidance would be appreciated!

BTW The reason I need to do this is that adding an un-escaped ampersand makes the page W3C invalid HTML. I don't really want to tell my users they cannot use ampersands.
A thread is for life. Not just for Christmas.

2
Peekay
Re: Escape ampersands in News title?
  • 2008/5/4 12:05

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


O.K., I was on the wrong route there!

submit.php
around line 323

replace:
$story->setTitle($_POST['title']);


with:
$story->setTitle(htmlentities($_POST['title']));


Works for me, but I guess I would need to change every title input field on every module. Would be interesting if anyone knows of a better, perhaps global solution.
A thread is for life. Not just for Christmas.

3
Peekay
Re: Escape ampersands in News title?
  • 2008/5/4 13:09

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


In SmartSection (2.13)

submit.php (for user submissions)
around line 176

replace:
$itemObj->setVar('title'$_POST['title']);

with:
$itemObj->setVar('title'htmlentities($_POST['title']));


admin/item.php (for admin submissions)

around line 578
replace:
$itemObj->setVar('title'$_POST['title']);


with:
$itemObj->setVar('title'htmlentities($_POST['title']));
A thread is for life. Not just for Christmas.

Login

Who's Online

345 user(s) are online (232 user(s) are browsing Support Forums)


Members: 0


Guests: 345


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