Skip to content

Commit

Permalink
1680: add sanitation of error-message from codeharbor
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoehn committed Feb 4, 2025
1 parent a4f52e5 commit 0849847
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/services/exercise_service/push_external.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def execute
if response.success?
nil
else
response.status == 401 ? I18n.t('exercises.export_codeharbor.not_authorized') : response.body
response.status == 401 ? I18n.t('exercises.export_codeharbor.not_authorized') : ERB::Util.html_escape(response.body)
end
rescue StandardError => e
e.message
Expand Down
12 changes: 10 additions & 2 deletions spec/services/exercise_service/push_external_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,19 @@

context 'when response status is 500' do
let(:status) { 500 }
let(:response) { 'an error occured' }
let(:response) { 'an error occurred' }

it { is_expected.to be response }
it { is_expected.to eql response }

context 'when response contains problematic characters' do
let(:response) { 'an <error> occurred' }

it { is_expected.to eql 'an &lt;error&gt; occurred' }
end
end


Check warning on line 63 in spec/services/exercise_service/push_external_spec.rb

View workflow job for this annotation

GitHub Actions / lint

[rubocop] reported by reviewdog 🐶 Extra blank line detected. Raw Output: spec/services/exercise_service/push_external_spec.rb:63:1: C: Layout/EmptyLines: Extra blank line detected.

Check warning on line 64 in spec/services/exercise_service/push_external_spec.rb

View workflow job for this annotation

GitHub Actions / lint

[rubocop] reported by reviewdog 🐶 Extra blank line detected. Raw Output: spec/services/exercise_service/push_external_spec.rb:64:1: C: Layout/EmptyLines: Extra blank line detected.
context 'when response status is 401' do
let(:status) { 401 }
let(:response) { I18n.t('exercises.export_codeharbor.not_authorized') }
Expand Down

0 comments on commit 0849847

Please sign in to comment.