Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Adjust regex to be more resilient #116

Conversation

MarmadileManteater
Copy link
Contributor

@MarmadileManteater MarmadileManteater commented Nov 2, 2022

Adjust regex to be more resilient

Pull Request Type

  • Bugfix
  • Feature Implementation
  • Documentation
  • Other

Related issue

Follow-up to #115
Closes #118

Description

I just realized that the regular expression used for finding channel names uses strings pulled from the YT response without sanitizing them first, and this will mean that any video with a symbol in the title could cause unexpected behavior. Vsauce is a really good example of this because they have lots of videos with weird symbols in the titles (EX: "mí͇͔̠śtk̥̞àẹ̶̢̪s "). I also added a loop to increase the likelihood that the channel name will be able to be successfully retrieved in channel page continuations.

If absolutely none of the videos in the continuation contain accessibility data which can be parsed, it still won't throw, but it will pass back the channelName as undefined. In FreeTube, this should just mean the channelName won't display at all under the video which isn't the best thing in the world, but it is still better than simply throwing in the case of a catastrophic failure.

Screenshots

before:
before
after:
after

`title` was being used in the regex, but I forgot to escape it.
The result was that titles with symbols which would normally be
interpreted as Regex throw.
Added loop to check every video object for metadata until it finds one
with something usable
@FreeTubeBot FreeTubeBot enabled auto-merge (squash) November 2, 2022 05:32
@MarmadileManteater MarmadileManteater changed the title Adjust regex to be more redundant Adjust regex to be more resilient Nov 2, 2022
@efb4f5ff-1298-471a-8973-3d47447115dc
Copy link
Member

efb4f5ff-1298-471a-8973-3d47447115dc commented Nov 2, 2022

Can u add Closes #116 in pr body? :)

@MarmadileManteater
Copy link
Contributor Author

Can u add Closes #116 in pr body? :)

I could be wrong, but I believe you mean #118 because #116 is this PR.

@efb4f5ff-1298-471a-8973-3d47447115dc

Oh thats my bad i meant #118

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

critical regex bugs in getChannelVideosMore()
5 participants