]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'testing' into 0.9.x
authorZach Copley <zach@status.net>
Mon, 1 Mar 2010 23:00:33 +0000 (15:00 -0800)
committerZach Copley <zach@status.net>
Mon, 1 Mar 2010 23:00:33 +0000 (15:00 -0800)
* testing:
  Upgrade XML output scrubbing to better deal with newline and a few other chars

1  2 
lib/util.php

diff --combined lib/util.php
index c7cb4f313ea459c270918046106bfa53f1a71450,7a170a5f5fd58684c94bce53d3802e6016a7778c..c1fc64a5a7c6fbb02e46cac0c4509c4c1aec2861
@@@ -770,13 -770,20 +770,13 @@@ function common_linkify($url) 
      }
  
      if (!empty($f)) {
 -        if ($f->isEnclosure()) {
 +        if ($f->getEnclosure()) {
              $is_attachment = true;
              $attachment_id = $f->id;
 -        } else {
 -            $foe = File_oembed::staticGet('file_id', $f->id);
 -            if (!empty($foe)) {
 -                // if it has OEmbed info, it's an attachment, too
 -                $is_attachment = true;
 -                $attachment_id = $f->id;
 -
 -                $thumb = File_thumbnail::staticGet('file_id', $f->id);
 -                if (!empty($thumb)) {
 -                    $has_thumb = true;
 -                }
 +
 +            $thumb = File_thumbnail::staticGet('file_id', $f->id);
 +            if (!empty($thumb)) {
 +                $has_thumb = true;
              }
          }
      }
@@@ -802,8 -809,28 +802,28 @@@ function common_shorten_links($text
  
  function common_xml_safe_str($str)
  {
-     // Neutralize control codes and surrogates
-       return preg_replace('/[\p{Cc}\p{Cs}]/u', '*', $str);
+     // Replace common eol and extra whitespace input chars
+     $unWelcome = array(
+         "\t",  // tab
+         "\n",  // newline
+         "\r",  // cr
+         "\0",  // null byte eos
+         "\x0B" // vertical tab
+     );
+     $replacement = array(
+         ' ', // single space
+         ' ',
+         '',  // nothing
+         '',
+         ' '
+     );
+     $str = str_replace($unWelcome, $replacement, $str);
+     // Neutralize any additional control codes and UTF-16 surrogates
+     // (Twitter uses '*')
+     return preg_replace('/[\p{Cc}\p{Cs}]/u', '*', $str);
  }
  
  function common_tag_link($tag)