Commit 70cc7dc0 authored by Stan Hu's avatar Stan Hu

Strip rspec-profiling output of NULL bytes

If a spec such as `wiki_pipeline_spec.rb` included a NULL byte in the
example text, then the `insert-rspec-profiling-data` script would fail
with an `invalid byte sequence` error
(e.g. https://gitlab.com/gitlab-org/gitlab/-/jobs/386527522).

To avoid this, we do two things:

1. Drop the NULL byte from the example test.
2. Modify the `insert-rspec-profiling-data` script to sanitize the CSV.

Closes https://gitlab.com/gitlab-org/gitlab/issues/120012
parent 2958a4b5
......@@ -35,6 +35,8 @@ def insert_data(path)
files.each do |filename|
puts "#{Time.now} Inserting #{filename}..."
# Strip file of NULL bytes to ensure data gets inserted
system("sed", "-i", "-e", "s/\\x00//g", filename)
result = RspecProfiling::Collectors::PSQL::Result.copy_from(filename)
puts "#{Time.now} Inserted #{result.cmd_tuples} lines in #{filename}, DB response: #{result.cmd_status}"
end
......
......@@ -230,7 +230,7 @@ describe Banzai::Pipeline::WikiPipeline do
]
invalid_slugs.each do |slug|
context "with the invalid slug #{slug}" do
context "with the invalid slug #{slug.delete("\000")}" do
invalid_js_links.each do |link|
it "doesn't include a prohibited slug in a (.) relative link '#{link}'" do
output = described_class.to_html(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment