Skip to content

Commit

Permalink
fix: add feed should validate feed id first
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Aug 6, 2024
1 parent f48b589 commit 767710d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/renderer/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const isSafari = memoize(() => {
// eslint-disable-next-line no-control-regex
export const isASCII = (str) => /^[\u0000-\u007F]*$/.test(str)

export const isBizId = (id) => {
export const isBizId = (id: string) => {
if (!id) return false

// id is uuid or snowflake
Expand Down
9 changes: 9 additions & 0 deletions src/renderer/src/modules/entry-column/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { EllipsisHorizontalTextWithTooltip } from "@renderer/components/ui/typog
import {
FEED_COLLECTION_LIST,
ROUTE_ENTRY_PENDING,
ROUTE_FEED_PENDING,
views,
} from "@renderer/constants"
import { shortcuts } from "@renderer/constants/shortcuts"
Expand Down Expand Up @@ -209,6 +210,14 @@ const AddFeedHelper = () => {
const feedId = useRouteParamsSelector((s) => s.feedId)
const feedQuery = useFeed({ id: feedId })

if (!feedId) { return }
if (feedId === FEED_COLLECTION_LIST || feedId === ROUTE_FEED_PENDING) {
return null
}
if (!isBizId(feedId)) {
return null
}

if (feedQuery.error && feedQuery.error.statusCode === 404) {
throw new FeedNotFound()
}
Expand Down

0 comments on commit 767710d

Please sign in to comment.