Save User's Web
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #1
Save User's Web
Is there any reason why MyBB saves the user's web field using htmlspecialchars() inside the escape_string()?

Sorry for this noob question Biggrin

07-12-2012 08:10 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Save User's Web
It's done twice in case one of them fails.
Oh, and the & character is evil - surely no website of concern has one of those buggers..

My Blog
07-12-2012 08:37 PM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #3
RE: Save User's Web
Some of my users use their profile page URL as their website. So the & character displayed as & in the source page, and &uid=x in the front end (profile page) because MyBB uses the htmlspecialchars_uni() in the profile page (and postbit).

07-13-2012 03:59 AM
Find all posts by this user Quote this message in a reply
Sama34 Offline
Senior Member
****
Posts: 490
Joined: May 2011
Post: #4
RE: Save User's Web
Maybe you can "fix" it with template conditionals php shortcut code. But no sure what function to use and if it will be save to do it.
Or you can write a plugin to redirect from member.php?profile=X to member.php?action=profile&uid=X and tell your users to use that instead?

Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
(This post was last modified: 07-13-2012 09:35 AM by Sama34.)
07-13-2012 09:33 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #5
RE: Save User's Web
(07-13-2012 09:33 AM)Sama34 Wrote:  Or you can write a plugin to redirect from member.php?profile=X to member.php?action=profile&uid=X and tell your users to use that instead?
No, the problem is that MyBB has a bug where it's double-escaping the user's website.

My Blog
07-13-2012 08:11 PM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #6
RE: Save User's Web
And again, personally (only my personal opinion), I think it is better to use a regex to verify the user's website field, like what XThreads does if we create a textbox and assign a Text Mask Filter (URI Generic, URL or URL (HTTP/S)) to the textbox?

Right now, I can see this in the user's website field:

Code:
http://This is my website. Ha ha ha ha!!!!!


But maybe it is because I'm not familiar with SEO URL.


07-14-2012 04:28 AM
Find all posts by this user Quote this message in a reply
Sama34 Offline
Senior Member
****
Posts: 490
Joined: May 2011
Post: #7
RE: Save User's Web
haha

Well, yes, it is a "bug, but unless you want to report it and they consider it worth fixing, you need to do something from your end.

You can write a plugin to check users websites before saving from the usercp. IMO, this field should be a profile field but that is no related to this, but we could use RateU's plugins to use regex.

Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
07-14-2012 05:02 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #8
RE: Save User's Web
I don't mind (personally) if the website field is in users table (although I prefer this as custom field). But I think it is a big bonus if MyBB adds more validation to it in the verify_website() function, and if it doesn't have any negative effect, do not htmlspecialchars() the value inside the escape_string() when saving to the db.

Because this is a default MyBB's field, maybe it is better if the above things is done by the default MyBB's userhandler.

But again, I don't know what a framework or a software should do to save a website/URL field.

07-14-2012 07:12 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #9
RE: Save User's Web
In general, you shouldn't escape stuff in the DB - the DB should store raw unescaped data, which should be escaped when displayed to the user.
(exception if you wish to cache parsing)

My Blog
07-14-2012 12:17 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: