gitcoinco / code_fund_ads

CodeFund is an open source platform that helps fund maintainers, bloggers, and builders through non-tracking ethical ads
https://codefund.io
GNU Affero General Public License v3.0
375 stars 104 forks source link

Replace invalid user agent strings with invalid characters #1323

Closed andrewmcodes closed 4 years ago

andrewmcodes commented 4 years ago

Type of PR

Description

This change should stop exceptions raising here because it cannot force encoding to UTF-8

[4] pry(main)> line = "test\x80"
=> "test\x80"
[5] pry(main)> line.encode(Encoding::UTF_8, invalid: :replace)
=> "test�"

This should also help pin down the issue and potentially find a long term fix. At minimum this should allow the impressions to still record.

Fixes #1322

Checklist

codecov[bot] commented 4 years ago

Codecov Report

Merging #1323 into master will increase coverage by 0.00%. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1323   +/-   ##
=======================================
  Coverage   34.75%   34.76%           
=======================================
  Files         345      345           
  Lines        7990     7989    -1     
=======================================
  Hits         2777     2777           
+ Misses       5213     5212    -1     
Impacted Files Coverage Δ
app/controllers/impressions_controller.rb 90.90% <ø> (+3.95%) :arrow_up:
app/jobs/schedule_organization_report_job.rb 86.20% <0.00%> (ø)