Skip to content

Add validation of report parameters#7037

Open
anovak4 wants to merge 1 commit into
openstreetmap:masterfrom
anovak4:fix-nonexistent-entry-report
Open

Add validation of report parameters#7037
anovak4 wants to merge 1 commit into
openstreetmap:masterfrom
anovak4:fix-nonexistent-entry-report

Conversation

@anovak4

@anovak4 anovak4 commented Apr 24, 2026

Copy link
Copy Markdown

Fixes #6970

Adds validation of the id and type parameters when creating a new report.

Previously, if you tried to report a nonexistent user or entry, you would be taken to a confusing page where you are reporting "/reports/new". Now, if the type or id are invalid, the user gets redirected to the main page and a warning popup telling the user "The item you are trying to report could not be found".

This situation is hard to run across from the typical user flow, but it's still good to protect against.

Comment thread app/controllers/reports_controller.rb
session_for(target_user)

# Invalid id
get new_report_path(:reportable_id => target_user.id + 1, :reportable_type => "User")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is just incrementing the user ID a safe way of guaranteeing an invalid user? I guess it probably is so long as users are created in monotonic order.

Also we should probably test the other item types?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: reporting a nonexistent user or diary entry

3 participants