Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Forum Module /

Discuss the Forum Module.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Membernames with ampersand throw exeption


Go to End


3 Posts   1366 Views

Avatar
baba-papa

Community Member, 279 Posts

15 September 2009 at 9:11pm

Hi,

I have one member in my Forum that has an "&" in his membername (Riley & Tood). If I try to view his profile in the frontend I get an errormessage:

<a href="/foren/">Foren</a> &raquo; Riley & Tood's Benutzerprofil
-------------------------------------------^

Is this a known bug?

Avatar
bummzack

Community Member, 904 Posts

15 September 2009 at 11:28pm

It's not a bug. It's just incorrectly escaped characters. In XML (and therefore also XHTML), & must be escaped to &amp;
What you could try is to ouput $Fieldname.XML in your template (instead of just $Fieldname)

Avatar
baba-papa

Community Member, 279 Posts

16 September 2009 at 3:38am

Hello Banal,

thanks for your help. After adding nickname.XML I found out that the problem came from the breadcrumbs. The breadcrumbs show the username when you view the user´s profile. I added an htmlentities() to ForumMemberProfile.php:

	public function Breadcrumbs() {
		$nonPageParts = array();
		$parts = array();

		$forumHolder = $this->ForumHolder();
		$member = $this->Member();
		
		$parts[] = "<a href=\"{$forumHolder->Link()}\">{$forumHolder->Title}</a>";
		$nonPageParts[] = htmlentities($this->Title);
...

I did some frontend testing and didn´t find any bug caused by that change.