Skip to content

Commit

Permalink
Merge pull request brave#1077 from brave/issues/2507
Browse files Browse the repository at this point in the history
strings should be UTF8, but also check ASCII without crashing in dev
  • Loading branch information
tmancey committed Dec 18, 2018
1 parent 04145ad commit dbaa399
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions components/brave_ads/browser/ad_notification.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,27 @@ std::unique_ptr<message_center::Notification> CreateAdNotification(
std::string* notification_id) {
*notification_id = kNotifierIdPrefix + notification_info.uuid;
message_center::RichNotificationData notification_data;

base::string16 advertiser;
if (base::IsStringUTF8(notification_info.advertiser)) {
base::UTF8ToUTF16(notification_info.advertiser.c_str(),
notification_info.advertiser.length(), &advertiser);
}

base::string16 text;
if (base::IsStringUTF8(notification_info.text)) {
base::UTF8ToUTF16(notification_info.text.c_str(),
notification_info.text.length(), &text);
}

// hack to prevent origin from showing in the notification
// since we're using that to get the notification_id to OpenSettings
notification_data.context_message = base::ASCIIToUTF16(" ");
auto notification = std::make_unique<message_center::Notification>(
message_center::NOTIFICATION_TYPE_SIMPLE,
*notification_id,
base::ASCIIToUTF16(notification_info.advertiser),
base::ASCIIToUTF16(notification_info.text),
advertiser,
text,
gfx::Image(),
base::string16(),
GURL("chrome://brave_ads/?" + *notification_id),
Expand Down

0 comments on commit dbaa399

Please sign in to comment.