diff options
Diffstat (limited to 'include/functions.php')
-rw-r--r-- | include/functions.php | 79 |
1 files changed, 40 insertions, 39 deletions
diff --git a/include/functions.php b/include/functions.php index 3e37d1d28..4d54f7e35 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1029,13 +1029,14 @@ "prev_feed" => __("Open previous feed"), "next_article_or_scroll" => __("Open next article (in combined mode, scroll down)"), "prev_article_or_scroll" => __("Open previous article (in combined mode, scroll up)"), - "next_article_page" => __("Scroll article by one page down"), - "prev_article_page" => __("Scroll article by one page up"), + "next_headlines_page" => __("Scroll headlines by one page down"), + "prev_headlines_page" => __("Scroll headlines by one page up"), "next_article_noscroll" => __("Open next article"), "prev_article_noscroll" => __("Open previous article"), - "next_article_noexpand" => __("Move to next article (don't expand or mark read)"), - "prev_article_noexpand" => __("Move to previous article (don't expand or mark read)"), - "search_dialog" => __("Show search dialog")), + "next_article_noexpand" => __("Move to next article (don't expand)"), + "prev_article_noexpand" => __("Move to previous article (don't expand)"), + "search_dialog" => __("Show search dialog"), + "cancel_search" => __("Cancel active search")), __("Article") => array( "toggle_mark" => __("Toggle starred"), "toggle_publ" => __("Toggle published"), @@ -1097,23 +1098,26 @@ return $hotkeys; } + // {3} - 3 panel mode only + // {C} - combined mode only function get_hotkeys_map() { $hotkeys = array( "k" => "next_feed", "j" => "prev_feed", "n" => "next_article_noscroll", "p" => "prev_article_noscroll", - //"(33)|PageUp" => "prev_article_page", - //"(34)|PageDown" => "next_article_page", + "N" => "article_page_down", + "P" => "article_page_up", "*(33)|Shift+PgUp" => "article_page_up", "*(34)|Shift+PgDn" => "article_page_down", - "(38)|Up" => "prev_article_or_scroll", - "(40)|Down" => "next_article_or_scroll", + "{3}(38)|Up" => "prev_article_or_scroll", + "{3}(40)|Down" => "next_article_or_scroll", "*(38)|Shift+Up" => "article_scroll_up", "*(40)|Shift+Down" => "article_scroll_down", "^(38)|Ctrl+Up" => "prev_article_noscroll", "^(40)|Ctrl+Down" => "next_article_noscroll", "/" => "search_dialog", + "\\" => "cancel_search", "s" => "toggle_mark", "S" => "toggle_publ", "u" => "toggle_unread", @@ -1121,8 +1125,6 @@ "o" => "open_in_new_window", "c p" => "catchup_below", "c n" => "catchup_above", - "N" => "article_scroll_down", - "P" => "article_scroll_up", "a W" => "toggle_widescreen", "a e" => "toggle_full_text", "e" => "email_article", @@ -1264,7 +1266,7 @@ $rewrite_base_url = $site_url ? $site_url : get_self_url_prefix(); - $entries = $xpath->query('(//a[@href]|//img[@src]|//video/source[@src]|//audio/source[@src]|//picture/source[@src])'); + $entries = $xpath->query('(//a[@href]|//img[@src]|//source[@srcset|@src])'); foreach ($entries as $entry) { @@ -1273,34 +1275,33 @@ rewrite_relative_url($rewrite_base_url, $entry->getAttribute('href'))); $entry->setAttribute('rel', 'noopener noreferrer'); + $entry->setAttribute("target", "_blank"); } if ($entry->hasAttribute('src')) { - $src = rewrite_relative_url($rewrite_base_url, $entry->getAttribute('src')); - $entry->setAttribute('src', $src); + $entry->setAttribute('src', + rewrite_relative_url($rewrite_base_url, $entry->getAttribute('src'))); } if ($entry->nodeName == 'img') { $entry->setAttribute('referrerpolicy', 'no-referrer'); $entry->setAttribute('loading', 'lazy'); + } - $entry->removeAttribute('width'); - $entry->removeAttribute('height'); + if ($entry->hasAttribute('srcset')) { + $tokens = explode(",", $entry->getAttribute('srcset')); - if ($entry->hasAttribute('src')) { - $is_https_url = parse_url($entry->getAttribute('src'), PHP_URL_SCHEME) === 'https'; + for ($i = 0; $i < count($tokens); $i++) { + $token = trim($tokens[$i]); - if (is_prefix_https() && !$is_https_url) { + list ($url, $width) = explode(" ", $token, 2); - if ($entry->hasAttribute('srcset')) { - $entry->removeAttribute('srcset'); - } + $url = rewrite_relative_url($rewrite_base_url, $url); - if ($entry->hasAttribute('sizes')) { - $entry->removeAttribute('sizes'); - } - } + $tokens[$i] = "$url $width"; } + + $entry->setAttribute("srcset", implode(", ", $tokens)); } if ($entry->hasAttribute('src') && @@ -1323,17 +1324,10 @@ $entry->parentNode->parentNode->replaceChild($p, $entry->parentNode); } else if ($entry->nodeName == 'img') { - if ($entry->parentNode) $entry->parentNode->replaceChild($p, $entry); - } } - - if (strtolower($entry->nodeName) == "a") { - $entry->setAttribute("target", "_blank"); - $entry->setAttribute("rel", "noopener noreferrer"); - } } $entries = $xpath->query('//iframe'); @@ -1363,7 +1357,7 @@ if ($_SESSION['hasSandbox']) $allowed_elements[] = 'iframe'; - $disallowed_attributes = array('id', 'style', 'class'); + $disallowed_attributes = array('id', 'style', 'class', 'width', 'height', 'allow'); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SANITIZE) as $plugin) { $retval = $plugin->hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id); @@ -1379,7 +1373,15 @@ $doc->removeChild($doc->firstChild); //remove doctype $doc = strip_harmful_tags($doc, $allowed_elements, $disallowed_attributes); - if ($highlight_words) { + $entries = $xpath->query('//iframe'); + foreach ($entries as $entry) { + $div = $doc->createElement('div'); + $div->setAttribute('class', 'embed-responsive'); + $entry->parentNode->replaceChild($div, $entry); + $div->appendChild($entry); + } + + if ($highlight_words && is_array($highlight_words)) { foreach ($highlight_words as $word) { // http://stackoverflow.com/questions/4081372/highlight-keywords-in-a-paragraph @@ -1769,6 +1771,7 @@ */ function error_json($code) { require_once "errors.php"; + global $ERRORS; @$message = $ERRORS[$code]; @@ -1889,9 +1892,7 @@ date_default_timezone_set('UTC'); $root_dir = dirname(dirname(__FILE__)); - if ('\\' === DIRECTORY_SEPARATOR) { - $ttrss_version['version'] = "UNKNOWN (Unsupported, Windows)"; - } else if (PHP_OS === "Darwin") { + if (PHP_OS === "Darwin") { $ttrss_version['version'] = "UNKNOWN (Unsupported, Darwin)"; } else if (file_exists("$root_dir/version_static.txt")) { $ttrss_version['version'] = trim(file_get_contents("$root_dir/version_static.txt")) . " (Unsupported)"; @@ -1902,7 +1903,7 @@ $cwd = getcwd(); chdir($root_dir); - exec('git --no-pager log --pretty='.escapeshellarg('version: %ct %h').' -n1 HEAD 2>&1', $output, $rc); + exec('git --no-pager log --pretty="version: %ct %h" -n1 HEAD 2>&1', $output, $rc); chdir($cwd); if (is_array($output) && count($output) > 0) { |