]> git.wh0rd.org Git - tt-rss.git/commitdiff
remove plaintext url rewriting for twitter posts
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 31 Jul 2013 10:58:14 +0000 (14:58 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 31 Jul 2013 10:58:16 +0000 (14:58 +0400)
include/functions.php

index 4d24d0e264925a582229754884c30e2beb3c253c..5b752124929e996ae463393aa60a066404591f1c 100644 (file)
 
                $res = trim($str); if (!$res) return '';
 
-               if (strpos($res, "href=") === false)
-                       $res = rewrite_urls($res);
-
                $charset_hack = '<head>
                        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                </head>';
 
        }
 
-       function rewrite_urls($html) {
-               libxml_use_internal_errors(true);
-
-               $charset_hack = '<head>
-                       <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
-               </head>';
-
-               $doc = new DOMDocument();
-               $doc->loadHTML($charset_hack . $html);
-               $xpath = new DOMXPath($doc);
-
-               $entries = $xpath->query('//*/text()');
-
-               foreach ($entries as $entry) {
-                       if (strstr($entry->wholeText, "://") !== false) {
-                               $text = preg_replace("/((?<!=.)((http|https|ftp)+):\/\/[^ ,!]+)/i",
-                                       "<a target=\"_blank\" href=\"\\1\">\\1</a>", $entry->wholeText);
-
-                               if ($text != $entry->wholeText) {
-                                       $cdoc = new DOMDocument();
-                                       $cdoc->loadHTML($charset_hack . $text);
-
-
-                                       foreach ($cdoc->childNodes as $cnode) {
-                                               $cnode = $doc->importNode($cnode, true);
-
-                                               if ($cnode) {
-                                                       $entry->parentNode->insertBefore($cnode);
-                                               }
-                                       }
-
-                                       $entry->parentNode->removeChild($entry);
-
-                               }
-                       }
-               }
-
-               $node = $doc->getElementsByTagName('body')->item(0);
-
-               // http://tt-rss.org/forum/viewtopic.php?f=1&t=970
-               if ($node)
-                       return $doc->saveXML($node);
-               else
-                       return $html;
-       }
-
        function filter_to_sql($filter, $owner_uid) {
                $query = array();