Allow HTML in all item content
RSS description may contain encoded entities
This commit is contained in:
parent
fe16ec7281
commit
c74d9ccb74
@ -56,7 +56,6 @@ class Data {
|
||||
published_on TEXT NOT NULL,
|
||||
updated_on TEXT,
|
||||
content TEXT NOT NULL,
|
||||
is_encoded BOOLEAN NOT NULL,
|
||||
is_read BOOLEAN NOT NULL DEFAULT 0,
|
||||
is_bookmarked BOOLEAN NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY (feed_id) REFERENCES feed (id))
|
||||
|
@ -129,8 +129,7 @@ class Feed {
|
||||
'published' => Data::formatDate(self::eltValue($item, 'pubDate')),
|
||||
'updated' => Data::formatDate($updNodes->length > 0 ? $updNodes->item(0)->textContent : null),
|
||||
'content' => $encNodes->length > 0 ? $encNodes->item(0)->textContent
|
||||
: self::eltValue($item, 'description'),
|
||||
'isEncoded' => $encNodes->length > 0
|
||||
: self::eltValue($item, 'description')
|
||||
];
|
||||
}
|
||||
|
||||
@ -148,7 +147,6 @@ class Feed {
|
||||
published_on = :published,
|
||||
updated_on = :updated,
|
||||
content = :content,
|
||||
is_encoded = :encoded,
|
||||
is_read = 0
|
||||
WHERE id = :id
|
||||
SQL);
|
||||
@ -156,7 +154,6 @@ class Feed {
|
||||
$query->bindValue(':published', $item['published']);
|
||||
$query->bindValue(':updated', $item['updated']);
|
||||
$query->bindValue(':content', $item['content']);
|
||||
$query->bindValue(':encoded', $item['isEncoded']);
|
||||
$query->bindValue(':id', $itemId);
|
||||
$query->execute();
|
||||
}
|
||||
@ -171,9 +168,9 @@ class Feed {
|
||||
private static function addItem(int $feedId, array $item, SQLite3 $db): void {
|
||||
$query = $db->prepare(<<<'SQL'
|
||||
INSERT INTO item (
|
||||
feed_id, item_guid, item_link, title, published_on, updated_on, content, is_encoded
|
||||
feed_id, item_guid, item_link, title, published_on, updated_on, content
|
||||
) VALUES (
|
||||
:feed, :guid, :link, :title, :published, :updated, :content, :encoded
|
||||
:feed, :guid, :link, :title, :published, :updated, :content
|
||||
)
|
||||
SQL);
|
||||
$query->bindValue(':feed', $feedId);
|
||||
@ -183,7 +180,6 @@ class Feed {
|
||||
$query->bindValue(':published', $item['published']);
|
||||
$query->bindValue(':updated', $item['updated']);
|
||||
$query->bindValue(':content', $item['content']);
|
||||
$query->bindValue(':encoded', $item['isEncoded']);
|
||||
$query->execute();
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,8 @@ page_head('Welcome'); ?>
|
||||
<article><?php
|
||||
if ($item) {
|
||||
while ($item) { ?>
|
||||
<p><a href=/item?id=<?=$item['id']?>><?=htmlentities($item['item_title'])?></a><br>
|
||||
<?=htmlentities($item['feed_title'])?><br><small><em><?=date_time($item['as_of'])?></em></small><?php
|
||||
<p><a href=/item?id=<?=$item['id']?>><?=$item['item_title']?></a><br>
|
||||
<?=$item['feed_title']?><br><small><em><?=date_time($item['as_of'])?></em></small><?php
|
||||
$item = $result->fetchArray(SQLITE3_ASSOC);
|
||||
}
|
||||
} else { ?>
|
||||
|
@ -51,7 +51,6 @@ if ($item) {
|
||||
|
||||
$published = date_time($item['published_on']);
|
||||
$updated = isset($item['updated_on']) ? date_time($item['updated_on']) : null;
|
||||
$isEncoded = (bool) $item['is_encoded'];
|
||||
|
||||
page_head(htmlentities("{$item['item_title']} | {$item['feed_title']}")); ?>
|
||||
<h1 class=item_heading>
|
||||
@ -62,13 +61,7 @@ page_head(htmlentities("{$item['item_title']} | {$item['feed_title']}")); ?>
|
||||
Published <?=date_time($item['published_on'])?><?=$updated && $updated != $published ? " (Updated $updated)" : ''?>
|
||||
</div>
|
||||
<article>
|
||||
<div class=item_content><?php
|
||||
if ($isEncoded) {
|
||||
echo str_replace('<a ', '<a target=_blank rel=noopener ', $item['content']);
|
||||
} else {
|
||||
echo htmlentities($item['content']);
|
||||
} ?>
|
||||
</div>
|
||||
<div class=item_content><?=str_replace('<a ', '<a target=_blank rel=noopener ', $item['content'])?></div>
|
||||
<form class=action_buttons action=/item method=POST>
|
||||
<input type=hidden name=id value=<?=$_GET['id']?>>
|
||||
<a href="/">Done</a>
|
||||
|
Loading…
Reference in New Issue
Block a user