Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Brave Ads crash when parsing country code from subdivision targeting code #6812

Merged
merged 1 commit into from
Oct 9, 2020

Conversation

tmancey
Copy link
Collaborator

@tmancey tmancey commented Oct 8, 2020

Resolves brave/brave-browser#12030

Submitter Checklist:

Test Plan:

  • Change device region to United States
  • Connect via VPN to United States
  • Rewrite response status code for GET /v5/getstate server endpoint to 304 using a tool such as Charles Proxy
  • Join rewards
  • Wait until ads has initialized
  • Attempt to view a targeted ad for a US subdivision such as US-OR (Oregon) [This is where the crash would occur]
  • Quit the browser
  • Remove the rewrite
  • Launch the browser
  • View a targeted ad for a US subdivision such as US-OR (Oregon)

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

Copy link
Contributor

@emerick emerick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -57,6 +57,10 @@ bool SubdivisionTargetingFrequencyCap::DoesRespectCap(
const std::string subdivision_targeting_code =
ads_->get_subdivision_targeting()->GetAdsSubdivisionTargetingCode();

if (subdivision_targeting_code.empty()) {
return false;
Copy link
Contributor

@yachtcaptain23 yachtcaptain23 Oct 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, should DoesRespectCap return false if the data is malformed? My impression, without insight in previous discussions, is that we should return true.

Copy link
Collaborator Author

@tmancey tmancey Oct 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If subdivision targeting has not been initialized we need to return false so that the ad is not shown outside of the intended region which is a part of the cap. Thanks

Copy link
Contributor

@moritzhaller moritzhaller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Brave Ads crash when parsing country code from subdivision targeting code
4 participants