mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 04:05:55 +00:00
tag-related fixes
1. move tag sanitization to feedparser common item class 2. enforce length limit on tags when parsing 3. support multiple tags passed via one dc:subject and other such elements, parse them as a comma-separated list 4. sort resulting tag list to prevent different order between feed updates 5. remove some duplicate code related to tag validation 6. allow + symbol in tags
This commit is contained in:
@@ -305,19 +305,9 @@ class Article extends Handler_Protected {
|
||||
post_int_id = ? AND owner_uid = ?");
|
||||
$sth->execute([$int_id, $_SESSION['uid']]);
|
||||
|
||||
$tags = FeedItem_Common::normalize_categories($tags);
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
$tag = Article::sanitize_tag($tag);
|
||||
|
||||
if (!Article::tag_is_valid($tag)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preg_match("/^[0-9]*$/", $tag)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// print "<!-- $id : $int_id : $tag -->";
|
||||
|
||||
if ($tag != '') {
|
||||
$sth = $this->pdo->prepare("INSERT INTO ttrss_tags
|
||||
(post_int_id, owner_uid, tag_name)
|
||||
@@ -331,7 +321,6 @@ class Article extends Handler_Protected {
|
||||
|
||||
/* update tag cache */
|
||||
|
||||
sort($tags_to_cache);
|
||||
$tags_str = join(",", $tags_to_cache);
|
||||
|
||||
$sth = $this->pdo->prepare("UPDATE ttrss_user_entries
|
||||
@@ -802,27 +791,6 @@ class Article extends Handler_Protected {
|
||||
return $rv;
|
||||
}
|
||||
|
||||
static function sanitize_tag($tag) {
|
||||
$tag = trim($tag);
|
||||
|
||||
$tag = mb_strtolower($tag, 'utf-8');
|
||||
|
||||
$tag = preg_replace('/[,\'\"\+\>\<]/', "", $tag);
|
||||
|
||||
if (DB_TYPE == "mysql") {
|
||||
$tag = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $tag);
|
||||
}
|
||||
|
||||
return $tag;
|
||||
}
|
||||
|
||||
static function tag_is_valid($tag) {
|
||||
if (!$tag || is_numeric($tag) || mb_strlen($tag) > 250)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static function get_article_image($enclosures, $content, $site_url) {
|
||||
|
||||
$article_image = "";
|
||||
|
||||
Reference in New Issue
Block a user