-
Notifications
You must be signed in to change notification settings - Fork 0
UX: show complete URL path if website domain is same as instance domain #5
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
base: url-handling-pre
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ def self.untrusted_attributes(*attrs) | |
| :bio_cooked, | ||
| :created_at, | ||
| :website, | ||
| :website_name, | ||
| :profile_background, | ||
| :card_background, | ||
| :location, | ||
|
|
@@ -133,6 +134,26 @@ def website | |
| object.user_profile.website | ||
| end | ||
|
|
||
| def website_name | ||
| website_host = URI(website.to_s).host rescue nil | ||
| discourse_host = Discourse.current_hostname | ||
| return if website_host.nil? | ||
| if website_host == discourse_host | ||
| # example.com == example.com | ||
| website_host + URI(website.to_s).path | ||
| elsif (website_host.split('.').length == discourse_host.split('.').length) && discourse_host.split('.').length > 2 | ||
| # www.example.com == forum.example.com | ||
| website_host.split('.')[1..-1].join('.') == discourse_host.split('.')[1..-1].join('.') ? website_host + URI(website.to_s).path : website_host | ||
| else | ||
| # example.com == forum.example.com | ||
| discourse_host.ends_with?("." << website_host) ? website_host + URI(website.to_s).path : website_host | ||
| end | ||
| end | ||
|
|
||
| def include_website_name | ||
| website.present? | ||
| end | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing
|
||
|
|
||
| def card_image_badge_id | ||
| object.user_profile.card_image_badge.try(:id) | ||
| end | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Website name leaks for hidden untrusted profiles
Medium Severity
The
websiteattribute is listed inuntrusted_attributes, hiding it from anonymous users viewing TL0 profiles. However,website_nameis not similarly protected. Previously, the client-side computedwebsiteNamerelied onmodel.websitebeing present in the payload, which it wouldn't be for restricted users. Nowwebsite_nameis computed server-side and always serialized, leaking the user's website hostname even whenwebsiteitself is intentionally hidden.Additional Locations (1)
app/serializers/user_serializer.rb#L136-L151