Kaynağa Gözat

fix bug with leading dot in cookie domains

David Rose 18 yıl önce
ebeveyn
işleme
a55c6be5cf
1 değiştirilmiş dosya ile 4 ekleme ve 1 silme
  1. 4 1
      panda/src/downloader/httpCookie.cxx

+ 4 - 1
panda/src/downloader/httpCookie.cxx

@@ -125,11 +125,14 @@ parse_set_cookie(const string &format, const URLSpec &url) {
 ////////////////////////////////////////////////////////////////////
 bool HTTPCookie::
 matches_url(const URLSpec &url) const {
+  if (_domain.empty()) {
+    return false;
+  }
   string server = url.get_server();
   if (server == _domain || 
       (server.length() > _domain.length() &&
        server.substr(server.length() - _domain.length()) == _domain &&
-       server[server.length() - _domain.length() - 1] == '.')) {
+       (_domain[0] == '.' || server[server.length() - _domain.length() - 1] == '.'))) {
     // The domain matches.
 
     string path = url.get_path();