Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers/url_helper_spec.rb')
-rw-r--r--spec/helpers/url_helper_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/helpers/url_helper_spec.rb b/spec/helpers/url_helper_spec.rb
new file mode 100644
index 00000000000..7955a41b63a
--- /dev/null
+++ b/spec/helpers/url_helper_spec.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe UrlHelper, feature_category: :integrations do
+ describe '#escaped_url' do
+ it 'escapes url' do
+ expect(helper.escaped_url('https://example.com?param=test value')).to eq('https://example.com?param=test%20value')
+ end
+
+ it 'escapes XSS injection' do
+ expect(helper.escaped_url('https://example.com?injected_here"+eval(1)+"'))
+ .to eq('https://example.com?injected_here%22+eval(1)+%22')
+ end
+
+ it 'returns nil if url is nil' do
+ expect(helper.escaped_url(nil)).to be_nil
+ end
+
+ it 'returns nil when url is invalid' do
+ expect(helper.escaped_url('https://?&*^invalid-url'))
+ .to be_nil
+ end
+ end
+end