From 7873d588227cba4c66e2535b1be631736415ef6f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 17 Mar 2013 15:32:44 +0400 Subject: implement proper last_marked/last_published feeds for proper sorting of published and marked virtual feeds, remove sorting by last_read workaround api: add pubsubhubbub ping when article is being set published bump schema --- include/functions.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index f17828d1d..bc8d48217 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1,6 +1,6 @@ Date: Sun, 17 Mar 2013 15:53:42 +0400 Subject: sanitize: move htmlawed rewriting to execute last so that we can keep LIBXML_NOEMPTYTAG to prevent stuck tags (which stil occur) and still not cause duplicate br tags. --- include/functions.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index bc8d48217..c8b3bbb90 100644 --- a/include/functions.php +++ b/include/functions.php @@ -2555,10 +2555,6 @@ $res = trim($str); if (!$res) return ''; - $config = array('safe' => 1, 'deny_attribute' => 'style, width, height, class, id', 'comment' => 1, 'cdata' => 1, 'balance' => 0); - $spec = 'img=width,height'; - $res = htmLawed($res, $config, $spec); - if (get_pref($link, "STRIP_IMAGES", $owner)) { $res = preg_replace('/]+>/is', '', $res); } @@ -2601,7 +2597,13 @@ $node = $doc->getElementsByTagName('body')->item(0); - return $doc->saveXML($node); + $res = $doc->saveXML($node, LIBXML_NOEMPTYTAG); + + $config = array('safe' => 1, 'deny_attribute' => 'style, width, height, class, id', 'comment' => 1, 'cdata' => 1, 'balance' => 0); + $spec = 'img=width,height'; + $res = htmLawed($res, $config, $spec); + + return $res; } function check_for_update($link) { -- cgit v1.2.3-54-g00ecf From 18f24d8e4cf70c8bf70839250f242461fd9453ba Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 17 Mar 2013 17:02:59 +0400 Subject: use saveHTML() in sanitize instead of saveXML() (refs #522) --- include/functions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index c8b3bbb90..6e48a700a 100644 --- a/include/functions.php +++ b/include/functions.php @@ -2595,9 +2595,10 @@ } } - $node = $doc->getElementsByTagName('body')->item(0); + //$node = $doc->getElementsByTagName('body')->item(0); - $res = $doc->saveXML($node, LIBXML_NOEMPTYTAG); + $doc->removeChild($doc->firstChild); //remove doctype + $res = $doc->saveHTML(); $config = array('safe' => 1, 'deny_attribute' => 'style, width, height, class, id', 'comment' => 1, 'cdata' => 1, 'balance' => 0); $spec = 'img=width,height'; -- cgit v1.2.3-54-g00ecf From 9955a134621e75a1490a2cdc75c2a00c23f54507 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 17 Mar 2013 21:04:16 +0400 Subject: properly allow false parameters passed through to API calls (refs #576) --- classes/api.php | 18 +++++++++--------- include/functions.php | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'include/functions.php') diff --git a/classes/api.php b/classes/api.php index 1ee620863..74464821f 100644 --- a/classes/api.php +++ b/classes/api.php @@ -109,10 +109,10 @@ class API extends Handler { function getFeeds() { $cat_id = db_escape_string($_REQUEST["cat_id"]); - $unread_only = (bool)db_escape_string($_REQUEST["unread_only"]); + $unread_only = sql_bool_to_bool($_REQUEST["unread_only"]); $limit = (int) db_escape_string($_REQUEST["limit"]); $offset = (int) db_escape_string($_REQUEST["offset"]); - $include_nested = (bool)db_escape_string($_REQUEST["include_nested"]); + $include_nested = sql_bool_to_bool($_REQUEST["include_nested"]); $feeds = $this->api_get_feeds($this->link, $cat_id, $unread_only, $limit, $offset, $include_nested); @@ -120,8 +120,8 @@ class API extends Handler { } function getCategories() { - $unread_only = (bool)db_escape_string($_REQUEST["unread_only"]); - $enable_nested = (bool)db_escape_string($_REQUEST["enable_nested"]); + $unread_only = sql_bool_to_bool($_REQUEST["unread_only"]); + $enable_nested = sql_bool_to_bool($_REQUEST["enable_nested"]); // TODO do not return empty categories, return Uncategorized and standard virtual cats @@ -180,14 +180,14 @@ class API extends Handler { $offset = (int)db_escape_string($_REQUEST["skip"]); $filter = db_escape_string($_REQUEST["filter"]); - $is_cat = (bool)db_escape_string($_REQUEST["is_cat"]); - $show_excerpt = (bool)db_escape_string($_REQUEST["show_excerpt"]); - $show_content = (bool)db_escape_string($_REQUEST["show_content"]); + $is_cat = sql_bool_to_bool($_REQUEST["is_cat"]); + $show_excerpt = sql_bool_to_bool($_REQUEST["show_excerpt"]); + $show_content = sql_bool_to_bool($_REQUEST["show_content"]); /* all_articles, unread, adaptive, marked, updated */ $view_mode = db_escape_string($_REQUEST["view_mode"]); - $include_attachments = (bool)db_escape_string($_REQUEST["include_attachments"]); + $include_attachments = sql_bool_to_bool($_REQUEST["include_attachments"]); $since_id = (int)db_escape_string($_REQUEST["since_id"]); - $include_nested = (bool)db_escape_string($_REQUEST["include_nested"]); + $include_nested = sql_bool_to_bool($_REQUEST["include_nested"]); $sanitize_content = true; /* do not rely on params below */ diff --git a/include/functions.php b/include/functions.php index 6e48a700a..b43fda3a1 100644 --- a/include/functions.php +++ b/include/functions.php @@ -852,7 +852,7 @@ } function sql_bool_to_bool($s) { - if ($s == "t" || $s == "1" || $s == "true") { + if ($s == "t" || $s == "1" || strtolower($s) == "true") { return true; } else { return false; -- cgit v1.2.3-54-g00ecf From c670a80ddd9b03bd4ea6d940a9ed682fd26248d7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 18 Mar 2013 11:00:44 +0400 Subject: cache minified js files --- cache/js/.empty | 0 include/functions.php | 28 ++++++++++++++++++++++++++++ include/sanity_check.php | 4 ++++ index.php | 10 +++------- prefs.php | 9 ++------- 5 files changed, 37 insertions(+), 14 deletions(-) create mode 100644 cache/js/.empty (limited to 'include/functions.php') diff --git a/cache/js/.empty b/cache/js/.empty new file mode 100644 index 000000000..e69de29bb diff --git a/include/functions.php b/include/functions.php index b43fda3a1..8c2ced801 100644 --- a/include/functions.php +++ b/include/functions.php @@ -3907,4 +3907,32 @@ return in_array($interface, class_implements($class)); } + function get_minified_js($files) { + require_once 'lib/jshrink/Minifier.php'; + + $rv = ''; + + foreach ($files as $js) { + if (!isset($_GET['debug'])) { + $cached_file = CACHE_DIR . "/js/$js.js"; + + if (file_exists($cached_file) && + is_readable($cached_file) && + filemtime($cached_file) >= filemtime("js/$js.js")) { + + $rv .= file_get_contents($cached_file); + + } else { + $minified = JShrink\Minifier::minify(file_get_contents("js/$js.js")); + file_put_contents($cached_file, $minified); + $rv .= $minified; + } + } else { + $rv .= file_get_contents("js/$js.js"); + } + } + + return $rv; + } + ?> diff --git a/include/sanity_check.php b/include/sanity_check.php index fcf548705..4925486a3 100644 --- a/include/sanity_check.php +++ b/include/sanity_check.php @@ -36,6 +36,10 @@ array_push($errors, "Data export cache is not writable (chmod -R 777 ".CACHE_DIR."/export)"); } + if (!is_writable(CACHE_DIR . "/js")) { + array_push($errors, "Javascript cache is not writable (chmod -R 777 ".CACHE_DIR."/js)"); + } + if (GENERATED_CONFIG_CHECK != EXPECTED_CONFIG_VERSION) { array_push($errors, "Configuration option checker sanity_config.php is outdated, please recreate it using ./utils/regen_config_checks.sh"); diff --git a/index.php b/index.php index 49fcfdf98..68d6fc753 100644 --- a/index.php +++ b/index.php @@ -95,13 +95,9 @@ } } - foreach (array("tt-rss", "functions", "feedlist", "viewfeed", "FeedTree") as $js) { - if (!isset($_GET['debug'])) { - echo JShrink\Minifier::minify(file_get_contents("js/$js.js")); - } else { - echo file_get_contents("js/$js.js"); - } - } + print get_minified_js(array("tt-rss", + "functions", "feedlist", "viewfeed", "FeedTree")); + ?> diff --git a/prefs.php b/prefs.php index 4027fd1fa..a47d00bce 100644 --- a/prefs.php +++ b/prefs.php @@ -54,13 +54,8 @@ } } - foreach (array("functions", "deprecated", "prefs") as $js) { - if (!isset($_GET['debug'])) { - echo JShrink\Minifier::minify(file_get_contents("js/$js.js")); - } else { - echo file_get_contents("js/$js.js"); - } - } + print get_minified_js(array("functions", "deprecated", "prefs")); + ?> -- cgit v1.2.3-54-g00ecf