Bug 1603746 - Check url for protocol at the beginning of the string r=chutten
authorJan-Erik Rediger <jrediger@mozilla.com>
Fri, 13 Dec 2019 16:33:04 +0000
changeset 506922 07ec23676b974d6be94b0e83a9fa342e82ac364b
parent 506921 8590ed6875bed721318fb8223e00933cf822b3ee
child 506923 77a6b06925100509d1f40190bd1048f6b6f44527
push id36915
push userrgurzau@mozilla.com
push dateFri, 13 Dec 2019 21:43:22 +0000
treeherdermozilla-central@f09f24f2b545 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschutten
bugs1603746
milestone73.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1603746 - Check url for protocol at the beginning of the string r=chutten Differential Revision: https://phabricator.services.mozilla.com/D57129
toolkit/components/telemetry/pingsender/pingsender_unix_common.cpp
--- a/toolkit/components/telemetry/pingsender/pingsender_unix_common.cpp
+++ b/toolkit/components/telemetry/pingsender/pingsender_unix_common.cpp
@@ -172,19 +172,19 @@ static size_t DummyWriteCallback(char* p
 // If we can't use curl's URL parsing (which is safer) we have to fallback
 // to this handwritten one (which is only as safe as we are clever.)
 bool FallbackIsValidDestination(const string& aUrl) {
   // Lowercase the url
   string url = aUrl;
   std::transform(url.begin(), url.end(), url.begin(),
                  [](unsigned char c) { return std::tolower(c); });
   // Strip off the scheme in the beginning
-  if (url.find_first_of("http://") != std::string::npos) {
+  if (url.find("http://") == 0) {
     url = url.substr(7);
-  } else if (url.find_first_of("https://") != std::string::npos) {
+  } else if (url.find("https://") == 0) {
     url = url.substr(8);
   }
 
   // Remove any user information. If a @ appeared in the userinformation,
   // it would need to be encoded.
   unsigned long atStart = url.find_first_of("@");
   url = (atStart == std::string::npos) ? url : url.substr(atStart + 1);