Display problems with name containing apostrophe

miky_italy - November 25, 2008 - 11:54
Project:RealName
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:NancyDru
Status:closed
Description

The Name displayed is corrupted when the fields that compose the realname contains apostrophe: i.e. Olga D'Amico
It display Olga D'Amico

#1

angelopc - November 25, 2008 - 11:57

That looks correct, to me.

#2

miky_italy - November 25, 2008 - 13:04

To me it display:

Olga D & # 0 3 9 ; Amico

without spaces between the D and the following A.

#3

NancyDru - November 27, 2008 - 16:40
Status:active» postponed (maintainer needs more info)

Yes, this is an ongoing argument with the core developers and arises out of the need to protect you from hackers.

Right now, my code is being updated for another issue, so I can't commit this fix yet, but it does seem to fix it (and I think gives me an idea for a core patch). In "function realname_make_name", on approximately line 319, you will find

        $stuff['%'. $i] = check_plain($account->$name);

Change that line to
        $stuff['%'. $i] = drupal_validate_utf8($account->$name) ? htmlspecialchars($account->$name, ENT_COMPAT) : '';

And let me know if that solves the problem.

#4

NancyDru - November 30, 2008 - 14:18
Assigned to:Anonymous» NancyDru
Status:postponed (maintainer needs more info)» fixed

Fix committed to 6.x only.

#5

miky_italy - December 4, 2008 - 10:51

Verified for the 5.x and your patch works correctly!
Thank you,
Michele

#6

Heine - December 4, 2008 - 11:15
Status:fixed» active

The suggested fix is wrong.

The appearance of &039; means that the name is passed twice through check_plain. The realname in realname_make_name should be treated as the plain text data it is; and escaped upon using it in another context. This means that you need to escape the name with check_plain the moment it is used in an HTML context.

As you can see from the theme_username documentation, it too treats the username as plaintext and escapes it upon output (either via l() or check_plain).

Please read Safe String Theory for the web and Handle text in a secure fashion for background.

My suggestion is to treat the name as plaintext in realname_make_name (do not use check_plain), and review the uses of the name elsewhere in the module for the need for escaping.

#7

NancyDru - December 30, 2008 - 21:30
Status:active» fixed

Thank you, Heine. I have read those references several times, which is why I use check_plain. Perhaps I use it too liberally.

I have removed the check_plain/htmlspecialchars entirely. Committed to both branches.

#8

System Message - January 13, 2009 - 21:40
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.