-
Notifications
You must be signed in to change notification settings - Fork 168
fix: add radix parameter to parseInt calls #1095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ export async function PATCH(req: Request, { params }: { params: Promise<{ id: st | |
| const email = user?.primaryEmailAddress?.emailAddress; | ||
|
|
||
| const { id } = await params; | ||
| const doubtId = parseInt(id); | ||
| const doubtId = parseInt(id, 10); | ||
|
|
||
| if (isNaN(doubtId)) { | ||
| return NextResponse.json({ error: "Invalid doubt ID" }, { status: 400 }); | ||
|
|
@@ -320,7 +320,7 @@ export async function DELETE(req: Request, { params }: { params: Promise<{ id: s | |
| } | ||
|
|
||
| const { id } = await params; | ||
| const doubtId = parseInt(id); | ||
| const doubtId = parseInt(id, 10); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The DELETE handler passes Severity Level: Major
|
||
|
|
||
| const [doubt] = await db.select().from(doubtsTable).where(and(eq(doubtsTable.id, doubtId), isNull(doubtsTable.deletedAt))).limit(1); | ||
| if (!doubt) return NextResponse.json({ error: "Doubt not found" }, { status: 404 }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,7 +55,7 @@ export async function GET(req: Request) { | |
| try { | ||
| const user = await currentUser(); | ||
| const email = user?.primaryEmailAddress?.emailAddress ?? null; | ||
| const classroomId = classroomIdStr ? parseInt(classroomIdStr) : null; | ||
| const classroomId = classroomIdStr ? parseInt(classroomIdStr, 10) : null; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Using Severity Level: Major
|
||
|
|
||
| if (classroomId && !email) { | ||
| return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: The identifier is parsed with
parseInt, which accepts partial strings such as12abc, negative values, and zero. A malformed path can therefore be interpreted as a different doubt ID instead of returning the invalid-ID response. Validate the entire value as a positive safe integer before querying the database. [api mismatch]Severity Level: Major⚠️
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖