for example:

modules/block/block.install:82:        'description' => t('Custom title for the block. (Empty string will use block default title, <none> will remove the title, text will cause block to use specified title.)'),

t() strings can use real tags as appropriate, but pseudo-tagss like this should use entities like &lt;

CommentFileSizeAuthor
#1 unescaped-bracket-329998-7x-1.patch2.01 KBpwolanin

Comments

pwolanin’s picture

Status: Active » Needs review
StatusFileSize
new2.01 KB

so far, I only turned up 3 such instances, all in schema descriptions.

robloach’s picture

Status: Needs review » Reviewed & tested by the community

I've also noticed some use of <?php tags and <tag> tags in the code comments too, which like to mess with some IDEs..... Is there an issue for that? Or should we merge that into this patch?

pwolanin’s picture

@Rob Loach - since the ones in t() strings are a blocker for the t-string validation patch, I'd rather keep them apart.

gábor hojtsy’s picture

Patch looks good. Should be checked whether it is escaped another time somewhere. It was displaying good before, so it might be double escaped now. Did not have the chance yet to double check.

pwolanin’s picture

in fact those strings are not escaped - if I turn on schema module the string displays as:

title	varchar(64)	NO	''
Custom title for the block. (Empty string will use block default title, will remove the title, text will cause block to use specified title.)

note that <none> does not display

gábor hojtsy’s picture

Ok, patch looks to be changing only schema descriptions, which are indeed only displayed by schema module. The tags are not valid HTML and so they should not be literally in the string anyway (t()-ed strings could contain tags, but these are not tags). So agreed that patch is good. Should even be committed to Drupal 6!

webchick’s picture

Version: 7.x-dev » 6.x-dev

Some thoughts:

a) In Szeged, we had a big long discussion about t() around the descriptions and it was the consensus of everyone at the table (who included Dries) that t()s should be removed from these descriptions. They mess up things because t() isn't available that early, and people discussed that no one is going to take the time to translate technical descriptions of stuff, since we also don't translate code comments for example. So that's something we should do in a future patch.

b) Ideally, I would really like schema API to be able to translate these descriptions into actual database comments that would make themselves visible in apps like PHPMyAdmin. With this patch, that means these descriptions would show up with weird garbage characters in these programs like <none>. IMO it's the *displayer's* job to escape these, so we should file a patch against Schema module to wrap these in htmlentities() itself.

However, both of these changes are too big for Drupal 6, and Drupal 6 needs a solution here. So I've committed this patch to 7.x so that it can be backported. But I'd love to see people working on the above three enhancements for Drupal 7 (remove t() from schema descriptions and allow schema API to translate descriptions into COMMENT = 'xxxx' statements which will undo this change, and patch schema API to htmlentitles() escape description output).

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Uhm, then it would be good to discuss whether schema API is supposed to allow HTML in descriptions. If it does, then these tags need to be escaped. If schema API just blindly runs htmlspecialchars and does not allow any HTML in descriptions (such as links to more docs), then this patch makes new Drupal releases incompatible with new schema module releases (fixed with escaping). The current code assumes that schema API does not escape and allow for markup (emphasis, links) in descriptions, just as form API allows for that.

This patch is important for a future fix in Drupal to filter translatable text, so that <none> and friends are not filtered out from translations as unsecure (non-whitelisted) markup.

Committed to Drupal 6.x.

webchick’s picture

Hm. Fair enough. I would personally err on the side of not allowing HTML here and just stick links in directly as URLs, which Schema module could turn into links on its display side. I'm trying to think of a reason to have any other kind of HTML here. I'm certain that someone will come along and try and justify the <blink> tag being an integral part of our database documentation. :D

Split off into #332123: Remove t() from all schema descriptions and #12201: Show table descriptions in PHPMyAdmin and other tools.

Status: Fixed » Closed (fixed)

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

c960657’s picture