]> git.wh0rd.org - tt-rss.git/blobdiff - include/functions2.php
convert to punycode for feed on idn hostname
[tt-rss.git] / include / functions2.php
index aab73d34291f61ab4ca903723734623fdfe6e947..6b6f5aa560b630d393b28f42c44e738fad2dcf78 100644 (file)
                                                array_push($attrs_to_remove, $attr);
                                        }
 
+                                       if ($attr->nodeName == 'href' && stripos($attr->value, 'javascript:') === 0) {
+                                               array_push($attrs_to_remove, $attr);
+                                       }
+
                                        if (in_array($attr->nodeName, $disallowed_attributes)) {
                                                array_push($attrs_to_remove, $attr);
                                        }
                        }
 
                        if ($zoom_mode) {
-                               $feed_title = "<a href=\"".htmlspecialchars($line["site_url"]).
-                                       "\" target=\"_blank\">".
-                                       htmlspecialchars($line["feed_title"])."</a>";
+                               $feed_title = htmlspecialchars($line["feed_title"]);
 
                                $rv['content'] .= "<div class=\"postFeedTitle\">$feed_title</div>";
 
                        $url .= '/';
                }
 
+               //convert IDNA hostname to punycode if possible
+               if (function_exists("idn_to_ascii")) {
+                       $parts = parse_url($url);
+                       if (mb_detect_encoding($parts['host']) != 'ASCII')
+                       {
+                               $parts['host'] = idn_to_ascii($parts['host']);
+                               $url = build_url($parts);
+                       }
+               }
+
                if ($url != "http:///")
                        return $url;
                else
 
                return $tmp;
        }
+
+       function get_upload_error_message($code) {
+
+               $errors = array(
+                       0 => __('There is no error, the file uploaded with success'),
+                       1 => __('The uploaded file exceeds the upload_max_filesize directive in php.ini'),
+                       2 => __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'),
+                       3 => __('The uploaded file was only partially uploaded'),
+                       4 => __('No file was uploaded'),
+                       6 => __('Missing a temporary folder'),
+                       7 => __('Failed to write file to disk.'),
+                       8 => __('A PHP extension stopped the file upload.'),
+               );
+
+               return $errors[$code];
+       }
 ?>