Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / net / base / host_port_pair.cc
index bc23a9a..6675692 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "net/base/host_port_pair.h"
 
+#include "base/logging.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
@@ -47,6 +48,15 @@ std::string HostPortPair::ToString() const {
 }
 
 std::string HostPortPair::HostForURL() const {
+  // TODO(rtenneti): Add support for |host| to have '\0'.
+  if (host_.find('\0') != std::string::npos) {
+    std::string host_for_log(host_);
+    size_t nullpos;
+    while ((nullpos = host_for_log.find('\0')) != std::string::npos) {
+      host_for_log.replace(nullpos, 1, "%00");
+    }
+    LOG(DFATAL) << "Host has a null char: " << host_for_log;
+  }
   // Check to see if the host is an IPv6 address.  If so, added brackets.
   if (host_.find(':') != std::string::npos) {
     DCHECK_NE(host_[0], '[');