Skip to content

Commit

Permalink
Merge pull request #4282 from jasonrsadler/5726-fix
Browse files Browse the repository at this point in the history
Special characters now show correctly on Vimeo.
  • Loading branch information
NejcZdovc authored Mar 4, 2020
2 parents 71f5117 + 307372c commit 97d4b04
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
17 changes: 14 additions & 3 deletions vendor/bat-native-ledger/src/bat/ledger/internal/media/vimeo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/json/json_reader.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "bat/ledger/internal/bat_helper.h"
#include "bat/ledger/internal/ledger_impl.h"
#include "bat/ledger/internal/media/vimeo.h"
#include "bat/ledger/internal/static_values.h"
Expand Down Expand Up @@ -99,7 +100,14 @@ std::string Vimeo::GetNameFromVideoPage(const std::string& data) {
return "";
}

return braveledger_media::ExtractData(data, ",\"display_name\":\"", "\"");
std::string publisher_name;
const std::string publisher_json_name =
braveledger_media::ExtractData(data, "\"display_name\":\"", "\"");
const std::string publisher_json = "{\"brave_publisher\":\"" +
publisher_json_name + "\"}";
braveledger_bat_helper::getJSONValue(
"brave_publisher", publisher_json, &publisher_name);
return publisher_name;
}

// static
Expand Down Expand Up @@ -250,9 +258,12 @@ std::string Vimeo::GetNameFromPublisherPage(const std::string& data) {
if (data.empty()) {
return "";
}

return braveledger_media::ExtractData(data,
std::string publisher_name = GetNameFromVideoPage(data);
if (publisher_name == "") {
return braveledger_media::ExtractData(data,
"<meta property=\"og:title\" content=\"", "\"");
}
return publisher_name;
}

// static
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ const char publisher_page[] =
"<div class=\"app_banner_cta\">Watch in our app</div><a "
"class=\"app_banner_button js-app_banner_open_app\" "
"data-deep-link=\"users/97518779\" data-source-context=\"profile\"><span "
"class=\"app_banner_button_text\">Open in app</span></a></div>";
"class=\"app_banner_button_text\">Open in app</span></a></div> "
"<script name=\"jsonBlob\">profile = { \"display_name\":\"Nejc\"}";

const char video_page[] =
"<link rel=\"pingback\" href=\"https://vimeo.com/_pingback\">"
Expand Down

0 comments on commit 97d4b04

Please sign in to comment.