AmyStephen wrote:
Author Link for Joomla! is changing the array element
created_by_alias to contain both the Name and a link. Nothing is escaping the text values in the Plugin.
Here's one example from that plugin:
Code:
$link = JRoute::_('index.php?option=com_contact&view=contact&id='. $result->slug .'&catid='.$result->catslug );
$link = '<a href="'.$link.'"><span class="small">'.$created_by.'</span></a>, ';
$row->created_by_alias .= $img_out.$link;
I assume when the core escapes the created by or created by alias field prior to presentation (as should be done), the link is corrupted by the escaping? Is that the issue?
To me, this is a good example of why the core must be the one to escape the output.
Shiflett says if PHP devs focus on 2 things: filter input and escape output, the top 5 PHP security problems are gone.
In Joomla!, the core escapes output when that output is presented in the layouts. There's no place safer to do so. One might argue that doing so within the View *after* the Plugins fire to might provide better protection when non-core template overrides are used (if the developer doesn't do their job right), but never before IMO.
Beat - you made the point in the Dev CMS thread that core should escape the output before the Plugins fire to prevent double-escaping. But, that's sort of impossible since we don't know what all the other Plugins might do. It's not a feasible solution, IMO.
My take is that core is doing it right. I might recommend core moving it to inside the view after the Plugins fire. Now, some of our practices as third party developers need to also find best practices. We shouldn't change an array element to include a link in a name field since core will escape that output prior to presentation. Instead, we should insert our modifications to the document by working with the article->text field to append in or replace what is needed.
Just my opinion - good questions.
Amy
Hi Amy,
Thank you for dropping in with a proposed solution and interesting arguments.
Just to clarify, I don't wish to reinvent the wheel or start any great debate about security in web-applications (and how to avoid all these emergency security-releases), if that would be the case, I would be starting a new topic, and my post would be loooong.
Please accept my comments to yours:
- it's not because a single third-party plugin doesn't do its own security job (escaping) that it's joomla's task (additionally, previously names were already escaped in the database, therefore, the database content was already trusted, so it's even not an error of that plugin !). Following that route, joomla could escape the whole component output to do the job of poor 3p devs ?
- altering content isn't an option for adding properly a link to the author's name, or to add some fancy markup to allow cool effects. Why ? because you will miss the automatic and very varied format that templates do apply to that output, and not follow the templates best joomla practices.
- you wrote: "you made the point in the Dev CMS thread that core should escape the output before the Plugins fire to prevent double-escaping" : please read my post again, I didn't make that point. Nor did I want to make any "point". I just did a heads-up about a regression in the Joomla API affecting most author information enhancing content plugins.
I agree with you that best place to properly html-sanitize output is ... at output, but taking in account the nature of the information to display:
1) You assuming unclean text, and all previous joomla 1.0.x and 1.5.x releases assumed clean html. Thus it broke backwards-compatibility. It's as simple as that. Ian's suggestion on dev list to assume (instead of the 2 previous unclean text or clean html) unclean html is fine for me too.
2) Plus that joomla-internal "fix" for a poor input escaping of previous releases on name, won't fix any 3pd templates that do override that output based on joomla's previous example. Creating a false feeling of safety. Correct and only safe security fix would be to sanitize the database during the joomla upgrade (I also proposed that).
That's my only message, together with a simple proposal for a solution to fix that. Not a "point", just facts.
I am happy with other solutions allowing as previously to:
a) add a link to author name, and maybe a photo, buttons or any cool enhancements
b) add nice markup, e.g. title information, or photo on hover
exactly there where the name is displayed by standard joomla templates, according to standard parameters of joomla content.
But apart of database sanitization at upgrade, or exceptionally moving a little up the chain the "late" *database input* escaping done at *output* as a bug-fix, I don't see another backwards compatible solution to this. But I'm open to better solution, and will stand corrected if I missed one allowing a) and b) above

Ian's proposal on the dev list could work too (without params, just default white/black list).
Just looking for a practical solution to this regression here. Nothing more.
geminorum wrote:
The question is, why not core treat $article->created_by_alias like $article->text. this future adds flexibility to Joomla! articles and usually is not just a field for name. I suggest core use some less harsh mechanism on escaping this kind of data.
Nobody have any problem with security and stuff but escaping everything, sometime causes lost of abilities and there is noway around for third party to practice this kind ability!
Indeed, good point. It's really "unclean text" vs "clean or unclean html". Ian's proposal on the devs list (link in my post above) to treat it as "unclean html" goes into that direction too.
Respectfully, Best regards,