Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

strip Byte Order Mark during authentication #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions brick/auth_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ namespace {

const char kValidResponseType[] = "application/json";

bool StartsWithBom(const std::string &s) {
if (s.length() < 3)
return false;

return s[0] == char(239)
&& s[1] == char(187)
&& s[2] == char(191);
}

std::string
GetOsMark() {
// TODO(buglloc): use app_token!
Expand Down Expand Up @@ -218,6 +227,8 @@ AuthClient::OnDownloadData(CefRefPtr<CefURLRequest> request,

CEF_REQUIRE_UI_THREAD();
body_ += std::string(static_cast<const char*>(data), data_length);
if (StartsWithBom(body_))
body_ = body_.substr(3);
}

// static methods
Expand Down