diff options
| author | 2022-03-22 23:12:22 +0100 | |
|---|---|---|
| committer | 2022-03-22 23:12:22 +0100 | |
| commit | b0a63355b66d0cc431c9b1af96622c2360207565 (patch) | |
| tree | 24bf04d71f7ecba33f807a0e4d4b8f5ae7c92dcf /lib/SimplePie/SimplePie.php | |
| parent | 7d00ad8ed75cae5dafd4ac1f2cc6e15e94333628 (diff) | |
SimplePie fix parsing of HTTP Links (#4283)
* SimplePie fix parsing of HTTP Links
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link
* https://datatracker.ietf.org/doc/html/rfc8288
Before, SimplePie was not able to parse something like
```
Link: <https://pubsubhubbub.appspot.com>; rel="hub", <https://pubsubhubbub.superfeedr.com>; rel=hub, <https://websubhub.com/hub>; rel="hub"
```
Diffstat (limited to 'lib/SimplePie/SimplePie.php')
| -rw-r--r-- | lib/SimplePie/SimplePie.php | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/SimplePie/SimplePie.php b/lib/SimplePie/SimplePie.php index bf4a66bb4..60edf5274 100644 --- a/lib/SimplePie/SimplePie.php +++ b/lib/SimplePie/SimplePie.php @@ -2726,12 +2726,14 @@ class SimplePie if (isset($this->data['headers']['link'])) { $link_headers = $this->data['headers']['link']; - if (is_string($link_headers)) { - $link_headers = array($link_headers); + if (is_array($link_headers)) { + $link_headers = implode(',', $link_headers); } - $matches = preg_filter('/<([^>]+)>; rel='.preg_quote($rel).'/', '$1', $link_headers); - if (!empty($matches)) { - return $matches; + // https://datatracker.ietf.org/doc/html/rfc8288 + if (is_string($link_headers) && + preg_match_all('/<(?P<uri>[^>]+)>\s*;\s*rel\s*=\s*(?P<quote>"?)' . preg_quote($rel) . '(?P=quote)\s*(?=,|$)/i', $link_headers, $matches)) + { + return $matches['uri']; } } |
