mirror of
https://github.com/discourse/discourse.git
synced 2026-08-05 10:47:46 -05:00
FIX: crash in Admin::PluginsController when plugin has nil commit URL path (#35186)
The `discourse_owned?` method in `lib/plugin/instance.rb` was calling `.split` on `parsed_commit_url.path` without checking if the path could be nil. This caused a 500 error on `/admin/plugins` when any plugin had a commit URL that parsed successfully but returned a nil path (e.g., plugins without a git remote configured). Added a nil check for `parsed_commit_url.path` to gracefully handle this edge case and prevent the crash. Also added a test case to verify the method returns false when the parsed URL has a nil path.
This commit is contained in:
@@ -624,7 +624,7 @@ class Plugin::Instance
|
||||
def discourse_owned?
|
||||
return false if commit_hash.blank?
|
||||
parsed_commit_url = UrlHelper.relaxed_parse(self.commit_url)
|
||||
return false if parsed_commit_url.blank?
|
||||
return false if parsed_commit_url.blank? || parsed_commit_url.path.blank?
|
||||
github_org = parsed_commit_url.path.split("/")[1]
|
||||
(github_org == "discourse" || github_org == "discourse-org") &&
|
||||
parsed_commit_url.host == "github.com"
|
||||
|
||||
Reference in New Issue
Block a user