<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[28614] trunk/WebCore</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/28614">28614</a></dd>
<dt>Author</dt> <dd>ap@webkit.org</dd>
<dt>Date</dt> <dd>2007-12-11 09:30:50 -0800 (Tue, 11 Dec 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>        Reviewed by Darin.

        http://bugs.webkit.org/show_bug.cgi?id=16325
        &lt;rdar://problem/5632997&gt; REGRESSION: www.xerox.ru doesn't work

        Fix this on Windows, too!

        Test: http/tests/misc/empty-cookie.html

        * platform/network/win/CookieJarWin.cpp:
        (WebCore::setCookies):
        (WebCore::cookies):
        Same fix as on Mac, translated into CF.

        * platform/win/CookieJarWin.cpp: Removed - the real one is in platform/network/win.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoreplatformnetworkwinCookieJarWincpp">trunk/WebCore/platform/network/win/CookieJarWin.cpp</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkWebCoreplatformwinCookieJarWincpp">trunk/WebCore/platform/win/CookieJarWin.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (28613 => 28614)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2007-12-11 13:22:38 UTC (rev 28613)
+++ trunk/WebCore/ChangeLog        2007-12-11 17:30:50 UTC (rev 28614)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2007-12-11  Alexey Proskuryakov  &lt;ap@webkit.org&gt;
+
+        Reviewed by Darin.
+
+        http://bugs.webkit.org/show_bug.cgi?id=16325
+        &lt;rdar://problem/5632997&gt; REGRESSION: www.xerox.ru doesn't work
+
+        Fix this on Windows, too!
+
+        Test: http/tests/misc/empty-cookie.html
+
+        * platform/network/win/CookieJarWin.cpp:
+        (WebCore::setCookies):
+        (WebCore::cookies):
+        Same fix as on Mac, translated into CF.
+
+        * platform/win/CookieJarWin.cpp: Removed - the real one is in platform/network/win.
+
</ins><span class="cx"> 2007-12-11  Christian Dywan  &lt;christian@twotoasts.de&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Alp Toker.
</span></span></pre></div>
<a id="trunkWebCoreplatformnetworkwinCookieJarWincpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/network/win/CookieJarWin.cpp (28613 => 28614)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/network/win/CookieJarWin.cpp        2007-12-11 13:22:38 UTC (rev 28613)
+++ trunk/WebCore/platform/network/win/CookieJarWin.cpp        2007-12-11 17:30:50 UTC (rev 28614)
</span><span class="lines">@@ -49,6 +49,10 @@
</span><span class="cx"> void setCookies(const KURL&amp; url, const KURL&amp; policyURL, const String&amp; value)
</span><span class="cx"> {
</span><span class="cx"> #if USE(CFNETWORK)
</span><ins>+    // &lt;rdar://problem/5632883&gt; CFHTTPCookieStorage happily stores an empty cookie, which would be sent as &quot;Cookie: =&quot;.
+    if (value.isEmpty())
+        return;
+
</ins><span class="cx">     CFHTTPCookieStorageRef defaultCookieStorage = wkGetDefaultHTTPCookieStorage();
</span><span class="cx">     if (!defaultCookieStorage)
</span><span class="cx">         return;
</span><span class="lines">@@ -91,8 +95,18 @@
</span><span class="cx">     bool secure = equalIgnoringCase(url.protocol(), &quot;https&quot;);
</span><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;CFArrayRef&gt; cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookiesForURL(defaultCookieStorage, urlCF.get(), secure));
</span><del>-    RetainPtr&lt;CFDictionaryRef&gt; headerCF(AdoptCF, CFHTTPCookieCopyRequestHeaderFields(kCFAllocatorDefault, cookiesCF.get()));
</del><span class="cx"> 
</span><ins>+    // &lt;rdar://problem/5632883&gt; CFHTTPCookieStorage happily stores an empty cookie, which would be sent as &quot;Cookie: =&quot;.
+    // We have a workaround in setCookies() to prevent that, but we also need to avoid sending cookies that were previously stored.
+    CFIndex count = CFArrayGetCount(cookiesCF.get());
+    RetainPtr&lt;CFMutableArrayRef&gt; cookiesForURLFilteredCopy(AdoptCF, CFArrayCreateMutable(0, count, &amp;kCFTypeArrayCallBacks));
+    for (CFIndex i = 0; i &lt; count; ++i) {
+        CFHTTPCookieRef cookie = (CFHTTPCookieRef)CFArrayGetValueAtIndex(cookiesCF.get(), i);
+        if (CFStringGetLength(CFHTTPCookieGetName(cookie)) != 0)
+            CFArrayAppendValue(cookiesForURLFilteredCopy.get(), cookie);
+    }
+    RetainPtr&lt;CFDictionaryRef&gt; headerCF(AdoptCF, CFHTTPCookieCopyRequestHeaderFields(kCFAllocatorDefault, cookiesForURLFilteredCopy.get()));
+
</ins><span class="cx">     return (CFStringRef)CFDictionaryGetValue(headerCF.get(), s_cookieCF);
</span><span class="cx"> #else
</span><span class="cx">     DeprecatedString str = url.url();
</span></span></pre></div>
<a id="trunkWebCoreplatformwinCookieJarWincpp"></a>
<div class="delfile"><h4>Deleted: trunk/WebCore/platform/win/CookieJarWin.cpp (28613 => 28614)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/win/CookieJarWin.cpp        2007-12-11 13:22:38 UTC (rev 28613)
+++ trunk/WebCore/platform/win/CookieJarWin.cpp        2007-12-11 17:30:50 UTC (rev 28614)
</span><span class="lines">@@ -1,69 +0,0 @@
</span><del>-/*
- * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#include &quot;config.h&quot;
-#include &quot;KURL.h&quot;
-#include &quot;PlatformString.h&quot;
-#include &quot;DeprecatedString.h&quot;
-#include &lt;windows.h&gt;
-#include &lt;Wininet.h&gt;
-
-namespace WebCore
-{
-
-void setCookies(const KURL&amp; url, const KURL&amp; policyURL, const String&amp; value)
-{
-    // FIXME: Deal with the policy URL.
-    DeprecatedString str = url.url();
-    str.append((UChar)'\0');
-    DeprecatedString val = value.deprecatedString();
-    val.append((UChar)'\0');
-    InternetSetCookie((UChar*)str.unicode(), 0, (UChar*)val.unicode());
-}
-
-String cookies(const KURL&amp; url)
-{
-    DeprecatedString str = url.url();
-    str.append((UChar)'\0');
-
-    DWORD count;
-    InternetGetCookie((UChar*)str.unicode(), 0, 0, &amp;count);
-    if (count &lt;= 1) // Null terminator counts as 1.
-        return String();
-
-    UChar* buffer = new UChar[count];
-    InternetGetCookie((UChar*)str.unicode(), 0, buffer, &amp;count);
-    String&amp; result = String(buffer, count-1); // Ignore the null terminator.
-    delete[] buffer;
-    return result;
-}
-
-bool cookiesEnabled()
-{
-    // FIXME: For now just assume cookies are always on.
-    return true;
-}
-
-}
</del></span></pre>
</div>
</div>

</body>
</html>