docbrown/app
Daniel Uber 6f84f4afe8
Validate profile field "website url" is in fact a url (don't generate local path links). (#14302)
* Validate website_url profile field is a url

related to issue #14300

May need a data update script to (fixup? remove?) invalid profiles
since not being able to save existing profiles will cause problems.

* Check that URI is a valid url

Require the scheme to be one of https or http, not something like
mailto:// or telnet:// (nobody would do that, but don't try and link
to it if they did).

* Rubocop fixup for validation rule

URI::regexp is obsolete and should not be used. Instead, use URI::DEFAULT_PARSER.make_regexp

Prefer %w[] literals for arrays of words

Prefer the new style validations `validates :column, format: value` to validates_format_of

* Permit empty website_url fields

The previous validation was rejecting nil, which was the default. This
caused a lot of user factory calls to fail (since users didn't need
website urls in the profiles during testing unless the test was about
the website url link).

* Use :url validation as suggested

* Update validation error message

The validate_url gem gives a more complete error message to the
user. Update the spec to expect this.

* Use url_field rather than text_field in profile form

https://apidock.com/rails/v6.1.3.1/ActionView/Helpers/FormHelper/url_field

* Add data update to either fixup or clear invalid website urls

Checking blazer there are about 2600 profiles with "invalid" website
urls, typically a hostname, sometimes a hostname + path component,
which should be fixed up.

Naively add https:// to the front of the url, check that a valid
scheme and host are present on the resulting url, and save.

If an invalid url is generated (specifically, if host or scheme are
nil), just set the website url (with the invalid link) to an empty
string.

It's possible we'd want to notify users affected by this, that was not
included in this pass.

* Skip validations for intentionally invalid test cases
2021-07-22 12:02:29 -05:00
..
assets Delay the hover appearance of preview card (#14222) 2021-07-21 11:15:10 +01:00
black_box Remove <provider>_created_at columns (#13264) 2021-04-29 10:24:16 -05:00
controllers Add JSON representation of Profile Preview Card info (#14296) 2021-07-21 16:23:54 +01:00
decorators Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
errors Bump rubocop from 1.17.0 to 1.18.0 (#14107) 2021-07-01 13:51:49 +02:00
helpers Avoid showing social login options in ForemWebView (#14260) 2021-07-21 09:59:12 -06:00
javascript Add JSON representation of Profile Preview Card info (#14296) 2021-07-21 16:23:54 +01:00
lib Arrange Datadog Redis integrations more usefully (#14185) 2021-07-09 15:19:37 -04:00
liquid_tags Bump rubocop from 1.17.0 to 1.18.0 (#14107) 2021-07-01 13:51:49 +02:00
mailers Re-add dynamic delivery_method for ApplicationMailer (#13994) 2021-06-23 15:17:27 -04:00
models Validate profile field "website url" is in fact a url (don't generate local path links). (#14302) 2021-07-22 12:02:29 -05:00
policies Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
queries Bump rubocop from 1.17.0 to 1.18.0 (#14107) 2021-07-01 13:51:49 +02:00
refinements Drop profile columns from user (#10707) 2020-12-03 08:14:38 +07:00
sanitizers Remove unused attributes from markdown parser (#13484) 2021-04-27 09:33:01 -04:00
serializers Remove CustomProfileField (#14286) 2021-07-22 10:05:39 +07:00
services Remove CustomProfileField (#14286) 2021-07-22 10:05:39 +07:00
uploaders Change frame limit to match imgproxy (#13265) 2021-04-06 12:28:50 +02:00
validators Allow setting nil value in Settings::Upsert (#14228) 2021-07-20 10:57:09 -04:00
view_objects Rename SiteConfig to Settings::General (#13573) 2021-05-21 14:45:37 +02:00
views Validate profile field "website url" is in fact a url (don't generate local path links). (#14302) 2021-07-22 12:02:29 -05:00
workers Don't try to subscribe users without emails (#14244) 2021-07-15 10:34:23 -04:00