From e6905f7f875db71c934693732b3e03f852268e2c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 7 Jul 2016 10:02:55 +0300 Subject: test if mb_internal_encoding() is available in functions.php head --- include/functions.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/functions.php b/include/functions.php index d6bd5fb73..3ccc09d75 100755 --- a/include/functions.php +++ b/include/functions.php @@ -16,7 +16,9 @@ libxml_disable_entity_loader(true); - mb_internal_encoding("UTF-8"); + // separate test because this is included before sanity checks + if (function_exists("mb_internal_encoding")) mb_internal_encoding("UTF-8"); + date_default_timezone_set('UTC'); if (defined('E_DEPRECATED')) { error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); -- cgit v1.2.3-54-g00ecf From 64c24ecb5973adad700612b0ec913b190e8b1e58 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 26 Jul 2016 15:55:00 +0300 Subject: add hotkey for toggling VFEED_GROUP_BY_FEED preference --- include/functions2.php | 2 ++ js/tt-rss.js | 10 ++++++++++ 2 files changed, 12 insertions(+) (limited to 'include') diff --git a/include/functions2.php b/include/functions2.php index 0a4f4309e..aab73d342 100644 --- a/include/functions2.php +++ b/include/functions2.php @@ -89,6 +89,7 @@ "feed_edit" => __("Edit feed"), "feed_catchup" => __("Mark as read"), "feed_reverse" => __("Reverse headlines"), + "feed_toggle_vgroup" => __("Toggle headline grouping"), "feed_debug_update" => __("Debug feed update"), "feed_debug_viewfeed" => __("Debug viewfeed()"), "catchup_all" => __("Mark all feeds as read"), @@ -158,6 +159,7 @@ "f e" => "feed_edit", "f q" => "feed_catchup", "f x" => "feed_reverse", + "f g" => "feed_toggle_vgroup", "f *d" => "feed_debug_update", "f *g" => "feed_debug_viewfeed", "f *c" => "toggle_combined_mode", diff --git a/js/tt-rss.js b/js/tt-rss.js index 2f738810b..108b65a7f 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -441,6 +441,16 @@ function init() { hotkey_actions["feed_reverse"] = function() { reverseHeadlineOrder(); }; + hotkey_actions["feed_toggle_vgroup"] = function() { + var query_str = "?op=rpc&method=togglepref&key=VFEED_GROUP_BY_FEED"; + + new Ajax.Request("backend.php", { + parameters: query_str, + onComplete: function(transport) { + viewCurrentFeed(); + } }); + + }; hotkey_actions["catchup_all"] = function() { catchupAllFeeds(); }; -- cgit v1.2.3-54-g00ecf From dae16f72c9551584ccccce2e058f179f62b6ed09 Mon Sep 17 00:00:00 2001 From: JustAMacUser Date: Tue, 26 Jul 2016 03:51:22 -0400 Subject: Only strings need 4-byte filtering. --- include/rssfuncs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 include/rssfuncs.php (limited to 'include') diff --git a/include/rssfuncs.php b/include/rssfuncs.php old mode 100755 new mode 100644 index c01e703d1..21ffcbb76 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -778,7 +778,7 @@ foreach ($article as $k => $v) { // i guess we'll have to take the risk of 4byte unicode labels & tags here - if (!is_array($article[$k])) { + if (is_string($article[$k])) { $article[$k] = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $v); } } -- cgit v1.2.3-54-g00ecf From d8b0f06705812ef9e4ee4b1943f53dd82743db19 Mon Sep 17 00:00:00 2001 From: JustAMacUser Date: Sat, 6 Aug 2016 14:07:30 -0400 Subject: Remove href attribute if it executes JavaScript. --- include/functions2.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/functions2.php b/include/functions2.php index aab73d342..dceea507e 100644 --- a/include/functions2.php +++ b/include/functions2.php @@ -1064,6 +1064,10 @@ 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); } -- cgit v1.2.3-54-g00ecf From babfadbfd245ae8752ba379d594e5c158762a606 Mon Sep 17 00:00:00 2001 From: JustAMacUser Date: Sat, 6 Aug 2016 14:16:39 -0400 Subject: Pass the value of cache_images to plugins in HOOK_ARTICLE_FILTER. --- include/rssfuncs.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/rssfuncs.php b/include/rssfuncs.php index 21ffcbb76..522e4bf22 100644 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -726,7 +726,8 @@ "language" => $entry_language, "feed" => array("id" => $feed, "fetch_url" => $fetch_url, - "site_url" => $site_url) + "site_url" => $site_url, + "cache_images" => $cache_images) ); $entry_plugin_data = ""; -- cgit v1.2.3-54-g00ecf From 25a533c432036280de057bf10ca7b673e4f4aac4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 10 Aug 2016 09:15:52 +0300 Subject: bump static version to 16.8 --- include/version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/version.php b/include/version.php index 3169ff222..6ca1b7fc4 100644 --- a/include/version.php +++ b/include/version.php @@ -1,5 +1,5 @@ Date: Thu, 11 Aug 2016 15:01:01 +0300 Subject: perform housekeeping tasks for plugins loaded in user-context only --- include/functions.php | 9 ++++++--- include/rssfuncs.php | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/functions.php b/include/functions.php index 3ccc09d75..3902ac45a 100755 --- a/include/functions.php +++ b/include/functions.php @@ -833,14 +833,17 @@ return $csrf_token == $_SESSION['csrf_token']; } - function load_user_plugins($owner_uid) { + function load_user_plugins($owner_uid, $pluginhost = false) { + + if (!$pluginhost) $pluginhost = PluginHost::getInstance(); + if ($owner_uid && SCHEMA_VERSION >= 100) { $plugins = get_pref("_ENABLED_PLUGINS", $owner_uid); - PluginHost::getInstance()->load($plugins, PluginHost::KIND_USER, $owner_uid); + $pluginhost->load($plugins, PluginHost::KIND_USER, $owner_uid); if (get_schema_version() > 100) { - PluginHost::getInstance()->load_data(); + $pluginhost->load_data(); } } } diff --git a/include/rssfuncs.php b/include/rssfuncs.php index 522e4bf22..cbd011e5c 100644 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -179,6 +179,8 @@ $nf = 0; $bstarted = microtime(true); + $batch_owners = array(); + // For each feed, we call the feed update function. foreach ($feeds_to_update as $feed) { if($debug) _debug("Base feed: $feed"); @@ -204,6 +206,9 @@ while ($tline = db_fetch_assoc($tmp_result)) { if($debug) _debug(" => " . $tline["last_updated"] . ", " . $tline["id"] . " " . $tline["owner_uid"]); + if (array_search($tline["owner_uid"], $batch_owners) === FALSE) + array_push($batch_owners, $tline["owner_uid"]); + $fstarted = microtime(true); $rss = update_rss_feed($tline["id"], true, false); _debug_suppress(false); @@ -220,6 +225,12 @@ microtime(true) - $bstarted, (microtime(true) - $bstarted) / $nf)); } + foreach ($batch_owners as $owner_uid) { + _debug("Running housekeeping tasks for user $owner_uid..."); + + housekeeping_user($owner_uid); + } + require_once "digest.php"; // Send feed digests by email if needed. @@ -1502,6 +1513,14 @@ _debug("Removed $frows (feeds) $crows (cats) orphaned counter cache entries."); } + function housekeeping_user($owner_uid) { + $tmph = new PluginHost(); + + load_user_plugins($owner_uid, $tmph); + + $tmph->run_hooks(PluginHost::HOOK_HOUSE_KEEPING, "hook_house_keeping", ""); + } + function housekeeping_common($debug) { expire_cached_files($debug); expire_lock_files($debug); @@ -1517,6 +1536,5 @@ //_debug("Cleaned $rc cached tags."); PluginHost::getInstance()->run_hooks(PluginHost::HOOK_HOUSE_KEEPING, "hook_house_keeping", ""); - } ?> -- cgit v1.2.3-54-g00ecf From 1a322ff3dfb47a73f52f4076b9d73601999c573e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Aug 2016 18:14:22 +0300 Subject: import_export: better error message if upload failed --- include/functions2.php | 16 ++++++++++++++++ plugins/import_export/init.php | 43 +++++++++++++++++++++--------------------- 2 files changed, 38 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/include/functions2.php b/include/functions2.php index dceea507e..7e1171b7d 100644 --- a/include/functions2.php +++ b/include/functions2.php @@ -2449,4 +2449,20 @@ 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]; + } ?> diff --git a/plugins/import_export/init.php b/plugins/import_export/init.php index 7c628909f..491216e06 100644 --- a/plugins/import_export/init.php +++ b/plugins/import_export/init.php @@ -425,34 +425,35 @@ class Import_Export extends Plugin implements IHandler { print "
"; if ($_FILES['export_file']['error'] != 0) { - print_error(T_sprintf("Upload failed with error code %d", - $_FILES['export_file']['error'])); - return; - } + print_error(T_sprintf("Upload failed with error code %d (%s)", + $_FILES['export_file']['error'], + get_upload_error_message($_FILES['export_file']['error']))); + } else { - $tmp_file = false; + $tmp_file = false; - if (is_uploaded_file($_FILES['export_file']['tmp_name'])) { - $tmp_file = tempnam(CACHE_DIR . '/upload', 'export'); + if (is_uploaded_file($_FILES['export_file']['tmp_name'])) { + $tmp_file = tempnam(CACHE_DIR . '/upload', 'export'); - $result = move_uploaded_file($_FILES['export_file']['tmp_name'], - $tmp_file); + $result = move_uploaded_file($_FILES['export_file']['tmp_name'], + $tmp_file); - if (!$result) { - print_error(__("Unable to move uploaded file.")); + if (!$result) { + print_error(__("Unable to move uploaded file.")); + return; + } + } else { + print_error(__('Error: please upload OPML file.')); return; } - } else { - print_error(__('Error: please upload OPML file.')); - return; - } - if (is_file($tmp_file)) { - $this->perform_data_import($tmp_file, $_SESSION['uid']); - unlink($tmp_file); - } else { - print_error(__('No file uploaded.')); - return; + if (is_file($tmp_file)) { + $this->perform_data_import($tmp_file, $_SESSION['uid']); + unlink($tmp_file); + } else { + print_error(__('No file uploaded.')); + return; + } } print "