Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only allow http(s) scheme for urls (ref #3505) #3508

Merged
merged 1 commit into from
Jul 6, 2023
Merged

Conversation

Nutomic
Copy link
Member

@Nutomic Nutomic commented Jul 6, 2023

With this change only http(s) schemes are allowed for post.url field. This is checked for incoming api and federation requests. Existing posts in database which are sent to clients are not checked. Neither does it check urls in markdown.

@Nutomic Nutomic requested a review from dessalines as a code owner July 6, 2023 10:10
With this change only http(s) schemes are allowed for post.url
field. This is checked for incoming api and federation requests.
Existing posts in database which are sent to clients are not
checked. Neither does it check urls in markdown.
@Nutomic Nutomic force-pushed the filter-url-schema branch from be285c8 to eaf0fbf Compare July 6, 2023 10:44
@@ -302,12 +302,22 @@ pub fn check_site_visibility_valid(
Ok(())
}

pub fn check_url_scheme(url: &Option<Url>) -> LemmyResult<()> {
if let Some(url) = url {
if url.scheme() != "http" && url.scheme() != "https" {
Copy link
Member

Choose a reason for hiding this comment

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

["https", "http"].iter().any(|s| s == &url.scheme())

Copy link
Member Author

Choose a reason for hiding this comment

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

This is too confusing for such a simple check.

@dessalines dessalines merged commit 00f9f79 into main Jul 6, 2023
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.

3 participants