A platform for community discussion. Free, open, simple.
FIX: Drop internal URL validation for paths in sidebar (#20891)
Krzysztof Kotlarekc86d772277be
diff --git a/app/models/sidebar_url.rb b/app/models/sidebar_url.rbindex ad94de39a02..a969d2eee0d 100644--- a/app/models/sidebar_url.rb+++ b/app/models/sidebar_url.rb@@ -15,11 +15,8 @@ class SidebarUrl < ActiveRecord::Basebefore_validation :remove_internal_hostname, :set_externaldef path_validator- if external?- raise ActionController::RoutingError.new("Not Found") if value !~ Discourse::Utils::URI_REGEXP- else- Rails.application.routes.recognize_path(value)- end+ return true if !external?+ raise ActionController::RoutingError.new("Not Found") if value !~ Discourse::Utils::URI_REGEXPrescue ActionController::RoutingErrorerrors.add(:value,diff --git a/spec/models/sidebar_url_spec.rb b/spec/models/sidebar_url_spec.rbindex 37d5218b0cd..4542f399456 100644--- a/spec/models/sidebar_url_spec.rb+++ b/spec/models/sidebar_url_spec.rb@@ -1,13 +1,7 @@# frozen_string_literal: trueRSpec.describe SidebarUrl do- it "validates path" do- expect(SidebarUrl.new(icon: "link", name: "categories", value: "/categories").valid?).to eq(- true,- )- expect(SidebarUrl.new(icon: "link", name: "categories", value: "/invalid_path").valid?).to eq(- false,- )+ it "validates external URLs" doexpect(SidebarUrl.new(icon: "link",