diff options
| author | 2024-01-02 19:23:09 +0100 | |
|---|---|---|
| committer | 2024-01-02 19:23:09 +0100 | |
| commit | e240ee1caf80ffcb016a96d696f797f343c56f54 (patch) | |
| tree | e076798990dee5972dd3c9c19b42fc9310f86e2d /p/api/greader.php | |
| parent | 77108ea19e725022e6168753d19037d781b4f8fe (diff) | |
API allow negative feed IDs (#6010)
For future features (e.g. save articles by URL, save a manual note, ...), it would be good to allow special feeds, and to use negative integers for that. The rest of FreshRSS seems to be already ready, and there was only the Google Reader API, which required positive integers for feed IDs.
I quickly tested apps such as News+, EasyRSS, Rreadrops, which seem fine with that, but help welcome to test compatibility more thoroughly.
Diffstat (limited to 'p/api/greader.php')
| -rw-r--r-- | p/api/greader.php | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/p/api/greader.php b/p/api/greader.php index 5f351195c..f8390e3ef 100644 --- a/p/api/greader.php +++ b/p/api/greader.php @@ -419,7 +419,7 @@ final class GReaderAPI { if (strpos($streamUrl, 'feed/') === 0) { $streamUrl = '' . preg_replace('%^(feed/)+%', '', $streamUrl); $feedId = 0; - if (ctype_digit($streamUrl)) { + if (is_numeric($streamUrl)) { if ($action === 'subscribe') { continue; } @@ -592,11 +592,11 @@ final class GReaderAPI { string $filter_target, string $exclude_target, int $start_time, int $stop_time): array { switch ($type) { case 'f': //feed - if ($streamId != '' && is_string($streamId) && !ctype_digit($streamId)) { + if ($streamId != '' && is_string($streamId) && !is_numeric($streamId)) { $feedDAO = FreshRSS_Factory::createFeedDao(); $streamId = htmlspecialchars($streamId, ENT_COMPAT, 'UTF-8'); $feed = $feedDAO->searchByUrl($streamId); - $streamId = $feed == null ? -1 : $feed->id(); + $streamId = $feed == null ? 0 : $feed->id(); } break; case 'c': //category or label @@ -946,7 +946,7 @@ final class GReaderAPI { $entryDAO = FreshRSS_Factory::createEntryDao(); if (strpos($streamId, 'feed/') === 0) { $f_id = basename($streamId); - if (!ctype_digit($f_id)) { + if (!is_numeric($f_id)) { self::badRequest(); } $f_id = (int)$f_id; @@ -1068,7 +1068,7 @@ final class GReaderAPI { if (isset($pathInfos[6]) && isset($pathInfos[7])) { if ($pathInfos[6] === 'feed') { $include_target = $pathInfos[7]; - if ($include_target != '' && !ctype_digit($include_target)) { + if ($include_target != '' && !is_numeric($include_target)) { $include_target = empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI']; if (preg_match('#/reader/api/0/stream/contents/feed/([A-Za-z0-9\'!*()%$_.~+-]+)#', $include_target, $matches) === 1) { $include_target = urldecode($matches[1]); |
