codidact / qpixel

Q&A-based community knowledge-sharing software
https://codidact.com
GNU Affero General Public License v3.0
385 stars 69 forks source link

Fix invalid profile website URI causing a 500 error page on invalid URIs #1188

Closed Oaphi closed 1 year ago

Oaphi commented 1 year ago

This is a minor PR fixing #1169 by adding a validate_profile_website method to the users controller. The core of the issue is an unguarded attempt to parse the provided URI with URI.parse, which throws a URI::InvalidURIError on invalid URIs. Here is a preview that everything seems to be working as expected now:

Screencast from 23.08.2023 13:31:38.webm

I opted to remove the URI from the parameters and notify the user as I believe this is not severe enough to cause other valid changes to fail.