mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
return invalid url if feed url is different from user provided url
This commit is contained in:
parent
696de8ea50
commit
f6e04daf60
4 changed files with 15 additions and 2 deletions
|
|
@ -2790,6 +2790,7 @@ export enum SubscribeErrorCode {
|
|||
AlreadySubscribed = 'ALREADY_SUBSCRIBED',
|
||||
BadRequest = 'BAD_REQUEST',
|
||||
ExceededMaxSubscriptions = 'EXCEEDED_MAX_SUBSCRIPTIONS',
|
||||
InvalidUrl = 'INVALID_URL',
|
||||
NotFound = 'NOT_FOUND',
|
||||
Unauthorized = 'UNAUTHORIZED'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2190,6 +2190,7 @@ enum SubscribeErrorCode {
|
|||
ALREADY_SUBSCRIBED
|
||||
BAD_REQUEST
|
||||
EXCEEDED_MAX_SUBSCRIPTIONS
|
||||
INVALID_URL
|
||||
NOT_FOUND
|
||||
UNAUTHORIZED
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import axios from 'axios'
|
||||
import { parseHTML } from 'linkedom'
|
||||
import { Brackets } from 'typeorm'
|
||||
import { Brackets, In } from 'typeorm'
|
||||
import {
|
||||
DEFAULT_SUBSCRIPTION_FOLDER,
|
||||
Subscription,
|
||||
|
|
@ -204,7 +204,7 @@ export const subscribeResolver = authorized<
|
|||
|
||||
// find existing subscription
|
||||
const existingSubscription = await getRepository(Subscription).findOneBy({
|
||||
url: feedUrl,
|
||||
url: In([feedUrl, input.url]), // check both user provided url and parsed url
|
||||
user: { id: uid },
|
||||
type: SubscriptionType.Rss,
|
||||
})
|
||||
|
|
@ -241,6 +241,16 @@ export const subscribeResolver = authorized<
|
|||
}
|
||||
}
|
||||
|
||||
if (feedUrl !== input.url) {
|
||||
log.info('feed url is different from user provided url', {
|
||||
feedUrl,
|
||||
inputUrl: input.url,
|
||||
})
|
||||
return {
|
||||
errorCodes: [SubscribeErrorCode.InvalidUrl],
|
||||
}
|
||||
}
|
||||
|
||||
// create new rss subscription
|
||||
const MAX_RSS_SUBSCRIPTIONS = env.subscription.feed.max
|
||||
|
||||
|
|
|
|||
|
|
@ -1737,6 +1737,7 @@ const schema = gql`
|
|||
NOT_FOUND
|
||||
ALREADY_SUBSCRIBED
|
||||
EXCEEDED_MAX_SUBSCRIPTIONS
|
||||
INVALID_URL
|
||||
}
|
||||
|
||||
union AddPopularReadResult = AddPopularReadSuccess | AddPopularReadError
|
||||
|
|
|
|||
Loading…
Reference in a new issue