summaryrefslogtreecommitdiff
path: root/classes/api.php
diff options
context:
space:
mode:
authorJustAMacUser <[email protected]>2015-11-23 14:25:04 -0500
committerJustAMacUser <[email protected]>2015-11-23 14:57:03 -0500
commit73c77ab0a5d4ac714abf09f9730b75556481bb88 (patch)
tree9e54f557ebd80848306d8888aded5a3efa2ade03 /classes/api.php
parent19e47ad60bc390b52cfe1545a6d401545e6568a5 (diff)
Add optional (default: true), boolean "sanitize" parameter to API::getArticle() method.
Diffstat (limited to 'classes/api.php')
-rw-r--r--[-rwxr-xr-x]classes/api.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/classes/api.php b/classes/api.php
index dfe9ef6cb..c3ea627fd 100755..100644
--- a/classes/api.php
+++ b/classes/api.php
@@ -2,7 +2,7 @@
class API extends Handler {
- const API_LEVEL = 12;
+ const API_LEVEL = 13;
const STATUS_OK = 0;
const STATUS_ERR = 1;
@@ -325,13 +325,17 @@ class API extends Handler {
function getArticle() {
$article_id = join(",", array_filter(explode(",", $this->dbh->escape_string($_REQUEST["article_id"])), is_numeric));
+ $sanitize_content = !isset($_REQUEST["sanitize"]) ||
+ sql_bool_to_bool($_REQUEST["sanitize"]);
if ($article_id) {
$query = "SELECT id,title,link,content,feed_id,comments,int_id,
marked,unread,published,score,note,lang,
".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
- author,(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title
+ author,(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title,
+ (SELECT site_url FROM ttrss_feeds WHERE id = feed_id) AS site_url,
+ (SELECT hide_images FROM ttrss_feeds WHERE id = feed_id) AS hide_images
FROM ttrss_entries,ttrss_user_entries
WHERE id IN ($article_id) AND ref_id = id AND owner_uid = " .
$_SESSION["uid"] ;
@@ -357,7 +361,6 @@ class API extends Handler {
"comments" => $line["comments"],
"author" => $line["author"],
"updated" => (int) strtotime($line["updated"]),
- "content" => $line["content"],
"feed_id" => $line["feed_id"],
"attachments" => $attachments,
"score" => (int)$line["score"],
@@ -366,6 +369,15 @@ class API extends Handler {
"lang" => $line["lang"]
);
+ if ($sanitize_content) {
+ $article["content"] = sanitize(
+ $line["content"],
+ sql_bool_to_bool($line['hide_images']),
+ false, $line["site_url"], false, $line["id"]);
+ } else {
+ $article["content"] = $line["content"];
+ }
+
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) {
$article = $p->hook_render_article_api(array("article" => $article));
}