Referencing this comment: http://drupal.org/node/814168#comment-3058826

I was trying to create a rss feed for statuses and noticed that characters like " are being scaped to " since facebook_status_views_plugin_row_rss.inc at line 34 is using check_plain() to filter statuses text, I think that should be changed to filter_xss() as aggregator module does.

Comments

icecreamyou’s picture

Priority: Normal » Minor
Status: Active » Needs work

Sorry for the delay, I was on vacation -- I think it should be filter_xss(urldecode()) but thanks for the patch and I will try to commit this as soon as I can.

icecreamyou’s picture

Title: Scaped characters in Views RSS style plugin for statuses » Escaped characters in Views RSS style plugin for statuses
Status: Needs work » Fixed

I don't know what I was thinking with urldecode(). Committed your patch to dev, thanks.

Status: Fixed » Closed (fixed)

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

d4rkngel’s picture

Version: 6.x-2.3 » 6.x-2.x-dev
Status: Closed (fixed) » Active
StatusFileSize
new4.24 KB

I think that this should be changed to filter_xss($status->status, array()); "currently filter_xss($status->status)" because $allowed_tags is set to array('a', 'em', 'strong', 'cite', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'); and I think that we shouldn't allow this tags on statuses feed, see attached image.

icecreamyou’s picture

Actually, it should probably be this:

$status_text = _facebook_status_run_filter($status->status);
if (variable_get('facebook_status_nl2br', 0)) {
  $status_text = nl2br($status_text);
}
$item->title = $status_text;

That's consistent with the way it works everywhere else in FBSS. (And it's standard to allow those tags in RSS feeds.)

Maybe it would be better to put the status in the "description" element though -- but then I don't know what would go in the title... maybe filter_xss($status->status, array()) for the title and a "less clean" version in the description.

d4rkngel’s picture

How about using $usernames_context_aware as the title and the status as the description (something like twitter), this also solves the issue that when an empty status has an attachment.


$status_text = _facebook_status_run_filter($status->status);
if (variable_get('facebook_status_nl2br', 0)) {
  $status_text = nl2br($status_text);
}

$args = array(
      '!poster' => filter_xss(theme('username', $poster), array()), // Not using $poster->name for realname compatibility
      '!owner' => filter_xss(theme('username', $owner), array()),
    );

    $item = new stdClass();
    
    if ($poster->uid == $owner->uid) {
      $item->title = t('!poster:', $args); 
    }
    else {
      $item->title = t('!poster » !owner:', $args);
    }
    
    $item->description = $status_text;

d4rkngel’s picture

StatusFileSize
new5.78 KB

See no more scaped characters:

icecreamyou’s picture

Status: Active » Needs work

Twitter doesn't do that. The username of the creator of the tweet is in the title, but so is the tweet.

$args = array(
      '!poster' => filter_xss(theme('username', $poster), array()), // Not using $poster->name for realname compatibility
      '!owner' => filter_xss(theme('username', $owner), array()),
    );

I believe that the $user->name property works with realname as long as the user object is loaded directly (i.e. using user_load()). The global $user object is incomplete so $GLOBALS['user']->name doesn't work. Regardless, I won't accept filter_rss(theme('username', $account)). It's messy. It may be possible to do something like module_exists('realname') ? $account->realname : $account->name if necessary.

The literal binary double-right-chevron symbol (») can't be directly inserted into the code. It needs to be either the HTML (») or the unicode ("\xC2\xBB").

This also needs to be in patch format

d4rkngel’s picture

Should we then let the status text in the title?

Ok, so here's the first tray.

icecreamyou’s picture

Should we then let the status text in the title?

Yes, the patch looks good except for that.

d4rkngel’s picture

Ok here's the second one

d4rkngel’s picture

Oops sorry, here's the patch again

icecreamyou’s picture

+    if ($poster->uid == $owner->uid) {
+      $item->title = t('!poster: ', $args);
+    }
+    else {
+      $item->title = t('!poster » !owner: ', $args);
+    }
+    $item->title .= $status_text;

The status text should be part of the translation here. (For example, in a right-to-left language, the translation would have the status on the left; but if we append it after translating, it will always be on the right.)

Additionally, the version of the status that goes in the title should be filter_xss($status->status, array()), not the version with the input filter run over it.

d4rkngel’s picture

Let's try this

EDIT: I was wondering if we should use check_plain() with usernames...

icecreamyou’s picture

Oh, yes, actually I meant to say that it should be e.g. @poster instead of !poster to make sure they are properly escaped. Other than that the patch looks good

d4rkngel’s picture

Ok, changes applied

icecreamyou’s picture

Status: Needs work » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

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