Merge branch '58062-tracing-url-template-render-using-string-format-does-not-play-well-with-urls' into 'master'
Switch back to using regexps in tracing_url_template Closes #58062 See merge request gitlab-org/gitlab-ce!25491
This commit is contained in:
commit
d413e4e465
2 changed files with 14 additions and 10 deletions
|
@ -27,10 +27,11 @@ module Gitlab
|
|||
def self.tracing_url
|
||||
return unless tracing_url_enabled?
|
||||
|
||||
tracing_url_template % {
|
||||
correlation_id: Gitlab::CorrelationId.current_id.to_s,
|
||||
service: Gitlab.process_name
|
||||
}
|
||||
# Avoid using `format` since it can throw TypeErrors
|
||||
# which we want to avoid on unsanitised env var input
|
||||
tracing_url_template.to_s
|
||||
.gsub(/\{\{\s*correlation_id\s*\}\}/, Gitlab::CorrelationId.current_id.to_s)
|
||||
.gsub(/\{\{\s*service\s*\}\}/, Gitlab.process_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,12 +44,15 @@ describe Gitlab::Tracing do
|
|||
|
||||
describe '.tracing_url' do
|
||||
where(:tracing_url_enabled?, :tracing_url_template, :correlation_id, :process_name, :tracing_url) do
|
||||
false | "https://localhost" | "123" | "web" | nil
|
||||
true | "https://localhost" | "123" | "web" | "https://localhost"
|
||||
true | "https://localhost?service=%{service}" | "123" | "web" | "https://localhost?service=web"
|
||||
true | "https://localhost?c=%{correlation_id}" | "123" | "web" | "https://localhost?c=123"
|
||||
true | "https://localhost?c=%{correlation_id}&s=%{service}" | "123" | "web" | "https://localhost?c=123&s=web"
|
||||
true | "https://localhost?c=%{correlation_id}" | nil | "web" | "https://localhost?c="
|
||||
false | "https://localhost" | "123" | "web" | nil
|
||||
true | "https://localhost" | "123" | "web" | "https://localhost"
|
||||
true | "https://localhost?service={{ service }}" | "123" | "web" | "https://localhost?service=web"
|
||||
true | "https://localhost?c={{ correlation_id }}" | "123" | "web" | "https://localhost?c=123"
|
||||
true | "https://localhost?c={{ correlation_id }}&s={{ service }}" | "123" | "web" | "https://localhost?c=123&s=web"
|
||||
true | "https://localhost?c={{ correlation_id }}" | nil | "web" | "https://localhost?c="
|
||||
true | "https://localhost?c={{ correlation_id }}&s=%22{{ service }}%22" | "123" | "web" | "https://localhost?c=123&s=%22web%22"
|
||||
true | "https://localhost?c={{correlation_id}}&s={{service}}" | "123" | "web" | "https://localhost?c=123&s=web"
|
||||
true | "https://localhost?c={{correlation_id }}&s={{ service}}" | "123" | "web" | "https://localhost?c=123&s=web"
|
||||
end
|
||||
|
||||
with_them do
|
||||
|
|
Loading…
Reference in a new issue