Fix block channel channel ID validation #4366
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix block channel channel ID validation
Pull Request Type
Related issue
Noticed while testing #4347
Description
This fixes the regex used to validate the channel IDs passed into the block channel box in the distraction free settings. The regex was missing the start (
^
) and end ($
) anchors, which means that this invalid stringbla-UCUQo7nzH1sXVpzL92VesANw-bla
would be seen as a valid channel ID, resulting in requests getting sent to YouTube and Invidious which then understandably errored. This pull request adds those missing anchors so that the regex test only returns true if the whole string matches, instead of just a substring, I also changed it from\S
, which is any non-whitespace character, to[\w-]
(A-Za-z0-9_-
), previously strings like this would be counted as validUC@@@@@@@@@@@@@@@@@@@@@@
too.Testing
bla-UCUQo7nzH1sXVpzL92VesANw-bla
UC@@@@@@@@@@@@@@@@@@@@@@
It should now show "Channel ID provided was invalid", instead of sending a request to YouTube and Invidious, erorring with "Error retrieving user with the ID provided. Please check again if the ID is correct."
Desktop