summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Daniel Smith <daniel@rdnlsmith.com> 2026-02-08 17:11:46 -0500
committerGravatar Daniel Smith <daniel@rdnlsmith.com> 2026-07-04 14:14:50 -0400
commitddcdb9c99fa9263d49cbd94725c67d1c04823d16 (patch)
treeaa9d1002b325be612a30fbe233caa885b61c748a
parentb2c50115baa36c217e939ee3ea8ecfae52f91abd (diff)
Don’t break NetNewsWire’s footnote detection1.29.1-customcustom
If NetNewsWire detects that a link points to a footnote within the same post, then tapping on that link will produce a popover displaying the text of said footnote. Otherwise, it is treated as a regular link and opened in the default web browser. Detecting a footnote requires two things: 1. The link URL must consist only of a fragment (i.e. it begins with `#`). 2. There must exist another element (typically `<li>`) in the post’s HTML with an `id` attribute matching the fragment (that is, the text after `#`). Because FreshRSS’s web frontend can display multiple articles at once, all relative URLs (including bare fragments) are automatically converted to absolute URLs at ingestion time, and `id` attributes are replaced with `data-sanitized-id` attributes. These changes avoid conflicts in the web UI, but they break NNW’s footnote detection. Since I use FreshRSS solely as a backend service for NNW (and other clients), it is reasonable for me to disable those two sanitization steps in order to take full advantage of NNW’s features. Remove `id` from the list of attributes to rename, and add it to the list of allowed attributes (as otherwise, it would be stripped entirely). Convert the `absolutize_url()` function into a no-op if the relative URL provided appears to be a local fragment.
-rw-r--r--app/Models/SimplePieCustom.php3
-rw-r--r--lib/simplepie/simplepie/src/Misc.php4
2 files changed, 6 insertions, 1 deletions
diff --git a/app/Models/SimplePieCustom.php b/app/Models/SimplePieCustom.php
index 89b98c701..a1ef33abd 100644
--- a/app/Models/SimplePieCustom.php
+++ b/app/Models/SimplePieCustom.php
@@ -61,7 +61,7 @@ final class FreshRSS_SimplePieCustom extends \SimplePie\SimplePie
$this->set_curl_options($curl_options);
$this->strip_comments(true);
- $this->rename_attributes(['id', 'class']);
+ $this->rename_attributes(['class']);
$this->allow_aria_attr(true);
$this->allow_data_attr(true);
$this->allowed_html_attributes([
@@ -69,6 +69,7 @@ final class FreshRSS_SimplePieCustom extends \SimplePie\SimplePie
'dir',
'draggable',
'hidden',
+ 'id',
'lang',
'role',
'title',
diff --git a/lib/simplepie/simplepie/src/Misc.php b/lib/simplepie/simplepie/src/Misc.php
index a31c22bb2..d72a69a88 100644
--- a/lib/simplepie/simplepie/src/Misc.php
+++ b/lib/simplepie/simplepie/src/Misc.php
@@ -50,6 +50,10 @@ class Misc
*/
public static function absolutize_url(string $relative, string $base)
{
+ if (str_starts_with($relative, "#")) {
+ return $relative;
+ }
+
$iri = \SimplePie\IRI::absolutize(new \SimplePie\IRI($base), $relative);
if ($iri === false) {
return false;