Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spouts\rss: Provide unencoded link #1188

Merged
merged 1 commit into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- Set 60 second timeout to spout HTTP requests to prevent a single feed blocking other updates ([#1104](https://github.com/SSilence/selfoss/issues/1104))
- Significantly improved accessibility ([#1133](https://github.com/SSilence/selfoss/pull/1133), [#1134](https://github.com/SSilence/selfoss/pull/1134) and [#1141](https://github.com/SSilence/selfoss/pull/1141))
- Fixed marking more than 1000 items as read at the same time ([#1182](https://github.com/SSilence/selfoss/issues/1182))
- Fixed loading full text on pages containing ampersands in URLs ([#1188](https://github.com/SSilence/selfoss/pull/1188))

### API changes
- `tags` attribute is now consistently array of strings, numbers are numbers and booleans are booleans. **This might break third-party clients that have not updated yet.** ([#948](https://github.com/SSilence/selfoss/pull/948))
Expand Down
8 changes: 6 additions & 2 deletions src/helpers/FeedReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function load($url) {
return [
// save fetched items
'items' => $this->simplepie->get_items(),
'htmlUrl' => @$this->simplepie->get_link(),
'htmlUrl' => htmlspecialchars_decode($this->simplepie->get_link(), ENT_COMPAT), // SimplePie sanitizes URLs
'spoutTitle' => $this->simplepie->get_title(),
];
}
Expand All @@ -72,7 +72,7 @@ public function load($url) {
* @return ?string
*/
public function getImageUrl() {
return $this->simplepie->get_image_url();
return htmlspecialchars_decode($this->simplepie->get_image_url(), ENT_COMPAT); // SimplePie sanitizes URLs
}

/**
Expand All @@ -81,6 +81,10 @@ public function getImageUrl() {
* @return ?string
*/
public function getFeedUrl() {
// SimplePie sanitizes URLs but it unescapes ampersands here.
// Since double quotes and angle brackets are excluded from URIs,
// we need not worry about them and consider this unescaped.
// https://tools.ietf.org/html/rfc2396#section-2.4.3
return $this->simplepie->subscribe_url();
}

Expand Down
3 changes: 2 additions & 1 deletion src/spouts/reddit/reddit2.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public function getTitle() {

public function getHtmlUrl() {
if ($this->items !== null && $this->valid()) {
return @current($this->items)['data']['url'];
// Reddit escapes HTML, we can get away with just ampersands, since quotes and angle brackets are excluded from URLs.
return htmlspecialchars_decode(current($this->items)['data']['url'], ENT_NOQUOTES);
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion src/spouts/rss/feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function getLink() {
if ($this->items !== null && $this->valid()) {
$link = @current($this->items)->get_link();

return $link;
return htmlspecialchars_decode($link, ENT_COMPAT); // SimplePie sanitizes URLs
}

return null;
Expand Down