<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>156295</bug_id>
          
          <creation_ts>2016-04-06 11:11:13 -0700</creation_ts>
          <short_desc>[SOUP] Implement PlatformCookieJar::addCookie</short_desc>
          <delta_ts>2016-04-27 16:31:51 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>156091</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Blaze Burg">bburg</reporter>
          <assigned_to name="Michael Catanzaro">mcatanzaro</assigned_to>
          <cc>bburg</cc>
    
    <cc>berto</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>cgarcia</cc>
    
    <cc>commit-queue</cc>
    
    <cc>danw</cc>
    
    <cc>gustavo</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>mrobinson</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1181297</commentid>
    <comment_count>0</comment_count>
    <who name="Blaze Burg">bburg</who>
    <bug_when>2016-04-06 11:11:13 -0700</bug_when>
    <thetext>Stub for implementing new CookieJar API.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1181462</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-04-06 16:54:17 -0700</bug_when>
    <thetext>Thanks for the heads-up on this!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1181547</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-04-06 19:56:51 -0700</bug_when>
    <thetext>Hey Brian, since you haven&apos;t landed your patch in bug #156091 yet, here&apos;s an implementation you can add to it:

void addCookie(const NetworkStorageSession&amp; session, const URL&amp;, const Cookie&amp; cookie)
{
    // Ref is consumed by soup_cookie_jar_add_cookie.
    SoupCookie* soupCookie = soup_cookie_new(cookie.name.utf8().data(), cookie.value.utf8().data(),
        cookie.domain.utf8().data(), cookie.path.utf8().data(), static_cast&lt;int&gt;(cookie.expires));
    soup_cookie_set_http_only(soupCookie, cookie.httpOnly);
    soup_cookie_set_secure(soupCookie, cookie.secure);
    if (cookie.session)
        soup_cookie_set_max_age(soupCookie, -1);

    SoupCookieJar* cookieJar = cookieJarForSession(session);
    soup_cookie_jar_add_cookie(cookieJar, soupCookie);
}

It compiles, and it might even work!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1181551</commentid>
    <comment_count>3</comment_count>
    <who name="Blaze Burg">bburg</who>
    <bug_when>2016-04-06 20:07:06 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; Hey Brian, since you haven&apos;t landed your patch in bug #156091 yet, here&apos;s an
&gt; implementation you can add to it:
&gt; 
&gt; void addCookie(const NetworkStorageSession&amp; session, const URL&amp;, const
&gt; Cookie&amp; cookie)
&gt; {
&gt;     // Ref is consumed by soup_cookie_jar_add_cookie.
&gt;     SoupCookie* soupCookie = soup_cookie_new(cookie.name.utf8().data(),
&gt; cookie.value.utf8().data(),
&gt;         cookie.domain.utf8().data(), cookie.path.utf8().data(),
&gt; static_cast&lt;int&gt;(cookie.expires));
&gt;     soup_cookie_set_http_only(soupCookie, cookie.httpOnly);
&gt;     soup_cookie_set_secure(soupCookie, cookie.secure);
&gt;     if (cookie.session)
&gt;         soup_cookie_set_max_age(soupCookie, -1);
&gt; 
&gt;     SoupCookieJar* cookieJar = cookieJarForSession(session);
&gt;     soup_cookie_jar_add_cookie(cookieJar, soupCookie);
&gt; }
&gt; 
&gt; It compiles, and it might even work!

Awesome! Let&apos;s land it separately though, so that it can be reviewed by someone familiar with Soup :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1181598</commentid>
    <comment_count>4</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2016-04-06 23:09:25 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; Hey Brian, since you haven&apos;t landed your patch in bug #156091 yet, here&apos;s an
&gt; implementation you can add to it:
&gt; 
&gt; void addCookie(const NetworkStorageSession&amp; session, const URL&amp;, const
&gt; Cookie&amp; cookie)
&gt; {
&gt;     // Ref is consumed by soup_cookie_jar_add_cookie.

This comment is very confusing. I normally use consume for floating references, meaning that the weak ref is converted to a normal ref, but SoupCookieJar is not even ref counted. So, I would not use Ref, and would say adopted instead of consumed.

&gt;     SoupCookie* soupCookie = soup_cookie_new(cookie.name.utf8().data(),
&gt; cookie.value.utf8().data(),
&gt;         cookie.domain.utf8().data(), cookie.path.utf8().data(),
&gt; static_cast&lt;int&gt;(cookie.expires));

I&apos;m not sure this is correct, max_age is the number of seconds since now, but expires is an exact date (stored as an interval in milliseconds, it seems). so, I think we should pass -1 here always, and then use soup_cookie_set_expires() converting the expires interval to a SoupDate.

&gt;     soup_cookie_set_http_only(soupCookie, cookie.httpOnly);
&gt;     soup_cookie_set_secure(soupCookie, cookie.secure);
&gt;     if (cookie.session)
&gt;         soup_cookie_set_max_age(soupCookie, -1);
&gt; 
&gt;     SoupCookieJar* cookieJar = cookieJarForSession(session);
&gt;     soup_cookie_jar_add_cookie(cookieJar, soupCookie);

This could be a single line, no need to keep the local variable. Actually, I think even the cookie transfer could be more obvious if we use a helper function to create a SoupCookie out of a Cookie and then simply do:

soup_cookie_jar_add_cookie(cookieJarForSession(session), toSoupCookie(cookie));

&gt; }
&gt; 
&gt; It compiles, and it might even work!

I&apos;m not sure it works . . . Please, check what expires actually means in both soup and WebCore.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1181652</commentid>
    <comment_count>5</comment_count>
    <who name="Dan Winship">danw</who>
    <bug_when>2016-04-07 05:35:56 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; I&apos;m not sure this is correct, max_age is the number of seconds since now,
&gt; but expires is an exact date (stored as an interval in milliseconds, it
&gt; seems). so, I think we should pass -1 here always, and then use
&gt; soup_cookie_set_expires() converting the expires interval to a SoupDate.

...unless...

&gt; &gt;     if (cookie.session)
&gt; &gt;         soup_cookie_set_max_age(soupCookie, -1);

...it&apos;s a session cookie. You only want to call one of set_expires() and set_max_age()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1181653</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-04-07 05:39:45 -0700</bug_when>
    <thetext>Thanks Dan.

(In reply to comment #4)
&gt; This comment is very confusing. I normally use consume for floating
&gt; references, meaning that the weak ref is converted to a normal ref, but
&gt; SoupCookieJar is not even ref counted. So, I would not use Ref, and would
&gt; say adopted instead of consumed.

OK.

&gt; expires is an exact date (stored as an interval in milliseconds, it
&gt; seems).

No way to tell from the struct. :(

&gt; so, I think we should pass -1 here always, and then use
&gt; soup_cookie_set_expires() converting the expires interval to a SoupDate.

Good idea.

&gt; This could be a single line, no need to keep the local variable.

OK.

&gt; Actually, I
&gt; think even the cookie transfer could be more obvious if we use a helper
&gt; function to create a SoupCookie out of a Cookie and then simply do:
&gt; 
&gt; soup_cookie_jar_add_cookie(cookieJarForSession(session),
&gt; toSoupCookie(cookie));

OK.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1181713</commentid>
    <comment_count>7</comment_count>
    <who name="Blaze Burg">bburg</who>
    <bug_when>2016-04-07 10:23:35 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; Thanks Dan.
&gt; 
&gt; (In reply to comment #4)
&gt; &gt; This comment is very confusing. I normally use consume for floating
&gt; &gt; references, meaning that the weak ref is converted to a normal ref, but
&gt; &gt; SoupCookieJar is not even ref counted. So, I would not use Ref, and would
&gt; &gt; say adopted instead of consumed.
&gt; 
&gt; OK.
&gt; 
&gt; &gt; expires is an exact date (stored as an interval in milliseconds, it
&gt; &gt; seems).
&gt; 
&gt; No way to tell from the struct. :(

It is milliseconds since the UNIX epoch. I added a comment in another patch to be landed, since I had this question as well.

&gt; 
&gt; &gt; so, I think we should pass -1 here always, and then use
&gt; &gt; soup_cookie_set_expires() converting the expires interval to a SoupDate.
&gt; 
&gt; Good idea.
&gt; 
&gt; &gt; This could be a single line, no need to keep the local variable.
&gt; 
&gt; OK.
&gt; 
&gt; &gt; Actually, I
&gt; &gt; think even the cookie transfer could be more obvious if we use a helper
&gt; &gt; function to create a SoupCookie out of a Cookie and then simply do:
&gt; &gt; 
&gt; &gt; soup_cookie_jar_add_cookie(cookieJarForSession(session),
&gt; &gt; toSoupCookie(cookie));
&gt; 
&gt; OK.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1181752</commentid>
    <comment_count>8</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-04-07 11:21:06 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; It is milliseconds since the UNIX epoch. I added a comment in another patch
&gt; to be landed, since I had this question as well.

Great. Another reminder not to assume....

Anyway, this was a bit tricky to handle properly; I was particularly disappointed to see it&apos;s impossible to portably convert from a double to a time_t, but fortunately WTF has better time functions than the standard library, so it wasn&apos;t needed in the end.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1181766</commentid>
    <comment_count>9</comment_count>
      <attachid>275904</attachid>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-04-07 11:39:10 -0700</bug_when>
    <thetext>Created attachment 275904
[SOUP] Implement PlatformCookieJar::addCookie</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1182067</commentid>
    <comment_count>10</comment_count>
      <attachid>275904</attachid>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2016-04-07 22:18:38 -0700</bug_when>
    <thetext>Comment on attachment 275904
[SOUP] Implement PlatformCookieJar::addCookie

View in context: https://bugs.webkit.org/attachment.cgi?id=275904&amp;action=review

&gt; Source/WebCore/platform/network/soup/CookieJarSoup.cpp:205
&gt; -void addCookie(const NetworkStorageSession&amp;, const URL&amp;, const Cookie&amp;)
&gt; +static SoupDate* msToSoupDate(double ms)
&gt;  {
&gt; -    // FIXME: implement this command. &lt;https://webkit.org/b/156295&gt;
&gt; -    notImplemented();
&gt; +    int year = msToYear(ms);
&gt; +    int dayOfYear = dayInYear(ms, year);
&gt; +    bool leapYear = isLeapYear(year);
&gt; +    int day = dayInMonthFromDayInYear(dayOfYear, leapYear);
&gt; +    int month = monthFromDayInYear(dayOfYear, leapYear);
&gt; +    int hour = msToHours(ms);
&gt; +    int minute = msToMinutes(ms);
&gt; +    int second = static_cast&lt;int&gt;(ms / 1000) % 60;
&gt; +    return soup_date_new(year, month, day, hour, minute, second);
&gt; +}

I don&apos;t understand this. If the WebCore cookie expires is the number of milliseconds elapsed since the epoch, can&apos;t we just convert from milliseconds to seconds and use soup_date_new_from_time_t?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1182153</commentid>
    <comment_count>11</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-04-08 07:59:55 -0700</bug_when>
    <thetext>(In reply to comment #10)
&gt; I don&apos;t understand this. If the WebCore cookie expires is the number of
&gt; milliseconds elapsed since the epoch, can&apos;t we just convert from
&gt; milliseconds to seconds and use soup_date_new_from_time_t?

Kinda, but I don&apos;t know what systems that might break on. Unfortunately there seems to be no portable way to convert from a double (or int) to a time_t. I wanted to assume that the time_t stores time in seconds since the epoch and do static_cast&lt;std::time_t&gt;(cookie.expires / 1000), but turns out C++ does not guarantee that; very frustrating. :(</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1186699</commentid>
    <comment_count>12</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-04-23 18:53:50 -0700</bug_when>
    <thetext>Carlos?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1186873</commentid>
    <comment_count>13</comment_count>
      <attachid>275904</attachid>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2016-04-24 23:57:42 -0700</bug_when>
    <thetext>Comment on attachment 275904
[SOUP] Implement PlatformCookieJar::addCookie

View in context: https://bugs.webkit.org/attachment.cgi?id=275904&amp;action=review

EWS is red, please submit a new patch for EWS before landing this

&gt; Source/WebCore/platform/network/soup/CookieJarSoup.cpp:204
&gt; +    int year = msToYear(ms);
&gt; +    int dayOfYear = dayInYear(ms, year);
&gt; +    bool leapYear = isLeapYear(year);
&gt; +    int day = dayInMonthFromDayInYear(dayOfYear, leapYear);
&gt; +    int month = monthFromDayInYear(dayOfYear, leapYear);
&gt; +    int hour = msToHours(ms);
&gt; +    int minute = msToMinutes(ms);
&gt; +    int second = static_cast&lt;int&gt;(ms / 1000) % 60;
&gt; +    return soup_date_new(year, month, day, hour, minute, second);

I still don&apos;t understand this, but if you say there&apos;s no better way, it&apos;s fine with me. I wonder if it would look simpler without using all the local variables, something like:

return soup_date_new(year, monthFromDayInYear(dayOfYear, leapYear), dayInMonthFromDayInYear(dayOfYear, leapYear), msToHours(ms), msToMinutes(ms), static_cast&lt;int&gt;(ms / 1000) % 60);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1187953</commentid>
    <comment_count>14</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-04-27 14:15:21 -0700</bug_when>
    <thetext>(In reply to comment #13)
&gt; I still don&apos;t understand this

C++ doesn&apos;t guarantee how time_t is used to store time. I think maybe POSIX guarantees it&apos;s seconds since the epoch, but I&apos;m not sure, and I think this code should be portable.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1187969</commentid>
    <comment_count>15</comment_count>
      <attachid>277540</attachid>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-04-27 15:09:57 -0700</bug_when>
    <thetext>Created attachment 277540
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1188005</commentid>
    <comment_count>16</comment_count>
      <attachid>277540</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2016-04-27 16:31:45 -0700</bug_when>
    <thetext>Comment on attachment 277540
Patch

Clearing flags on attachment: 277540

Committed r200159: &lt;http://trac.webkit.org/changeset/200159&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1188006</commentid>
    <comment_count>17</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2016-04-27 16:31:51 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>275904</attachid>
            <date>2016-04-07 11:39:10 -0700</date>
            <delta_ts>2016-04-27 15:09:52 -0700</delta_ts>
            <desc>[SOUP] Implement PlatformCookieJar::addCookie</desc>
            <filename>bug-156295-20160407133905.patch</filename>
            <type>text/plain</type>
            <size>2891</size>
            <attacher name="Michael Catanzaro">mcatanzaro</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTk5MTY1CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggNTY4ZDVlODcyNTc5Njcx
Yzk1ODVjODA2YWU3OTBjODYwMWFhODM2MS4uOTJjYzY2MDU4YWNiYjYwZGVkZjUxODcyYmM2ODgy
MWI0ODQ3MjI5OCAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0No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KKyAgICBp
bnQgaG91ciA9IG1zVG9Ib3Vycyhtcyk7CisgICAgaW50IG1pbnV0ZSA9IG1zVG9NaW51dGVzKG1z
KTsKKyAgICBpbnQgc2Vjb25kID0gc3RhdGljX2Nhc3Q8aW50PihtcyAvIDEwMDApICUgNjA7Cisg
ICAgcmV0dXJuIHNvdXBfZGF0ZV9uZXcoeWVhciwgbW9udGgsIGRheSwgaG91ciwgbWludXRlLCBz
ZWNvbmQpOworfQorCitzdGF0aWMgU291cENvb2tpZSogdG9Tb3VwQ29va2llKGNvbnN0IENvb2tp
ZSYgY29va2llKQoreworICAgIFNvdXBDb29raWUqIHNvdXBDb29raWUgPSBzb3VwX2Nvb2tpZV9u
ZXcoY29va2llLm5hbWUudXRmOCgpLmRhdGEoKSwgY29va2llLnZhbHVlLnV0ZjgoKS5kYXRhKCks
CisgICAgICAgIGNvb2tpZS5kb21haW4udXRmOCgpLmRhdGEoKSwgY29va2llLnBhdGgudXRmOCgp
LmRhdGEoKSwgLTEpOworICAgIHNvdXBfY29va2llX3NldF9odHRwX29ubHkoc291cENvb2tpZSwg
Y29va2llLmh0dHBPbmx5KTsKKyAgICBzb3VwX2Nvb2tpZV9zZXRfc2VjdXJlKHNvdXBDb29raWUs
IGNvb2tpZS5zZWN1cmUpOworICAgIGlmICghY29va2llLnNlc3Npb24pIHsKKyAgICAgICAgU291
cERhdGUqIGRhdGUgPSBtc1RvU291cERhdGUoY29va2llLmV4cGlyZXMpOworICAgICAgICBzb3Vw
X2Nvb2tpZV9zZXRfZXhwaXJlcyhzb3VwQ29va2llLCBkYXRlKTsKKyAgICAgICAgc291cF9kYXRl
X2ZyZWUoZGF0ZSk7CisgICAgfQorICAgIHJldHVybiBzb3VwQ29va2llOworfQorCit2b2lkIGFk
ZENvb2tpZShjb25zdCBOZXR3b3JrU3RvcmFnZVNlc3Npb24mIHNlc3Npb24sIGNvbnN0IFVSTCYs
IGNvbnN0IENvb2tpZSYgY29va2llKQoreworICAgIHNvdXBfY29va2llX2phcl9hZGRfY29va2ll
KGNvb2tpZUphckZvclNlc3Npb24oc2Vzc2lvbiksIHRvU291cENvb2tpZShjb29raWUpKTsKIH0K
IAogdm9pZCBnZXRIb3N0bmFtZXNXaXRoQ29va2llcyhjb25zdCBOZXR3b3JrU3RvcmFnZVNlc3Np
b24mIHNlc3Npb24sIEhhc2hTZXQ8U3RyaW5nPiYgaG9zdG5hbWVzKQo=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>277540</attachid>
            <date>2016-04-27 15:09:57 -0700</date>
            <delta_ts>2016-04-27 16:31:45 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-156295-20160427171027.patch</filename>
            <type>text/plain</type>
            <size>2827</size>
            <attacher name="Michael Catanzaro">mcatanzaro</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjAwMTUwCmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggMDQzMmZhMmQzYzU0ZGYy
NmMwMjU2MmUwMTg4YmRlNGQzOGE0YWZiYy4uNDJlYmE4NjI0YmY3MTllYWU3YmU4ZDA4MDdjZjE4
NGRhZTcyNzEwNyAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE1IEBACisyMDE2LTA0LTI3ICBNaWNo
YWVsIENhdGFuemFybyAgPG1jYXRhbnphcm9AaWdhbGlhLmNvbT4KKworICAgICAgICBbU09VUF0g
SW1wbGVtZW50IFBsYXRmb3JtQ29va2llSmFyOjphZGRDb29raWUKKyAgICAgICAgaHR0cHM6Ly9i
dWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTE1NjI5NQorCisgICAgICAgIFJldmlld2Vk
I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isgICAgU291cENvb2tpZSogc291cENvb2tpZSA9IHNvdXBfY29va2llX25ldyhjb29r
aWUubmFtZS51dGY4KCkuZGF0YSgpLCBjb29raWUudmFsdWUudXRmOCgpLmRhdGEoKSwKKyAgICAg
ICAgY29va2llLmRvbWFpbi51dGY4KCkuZGF0YSgpLCBjb29raWUucGF0aC51dGY4KCkuZGF0YSgp
LCAtMSk7CisgICAgc291cF9jb29raWVfc2V0X2h0dHBfb25seShzb3VwQ29va2llLCBjb29raWUu
aHR0cE9ubHkpOworICAgIHNvdXBfY29va2llX3NldF9zZWN1cmUoc291cENvb2tpZSwgY29va2ll
LnNlY3VyZSk7CisgICAgaWYgKCFjb29raWUuc2Vzc2lvbikgeworICAgICAgICBTb3VwRGF0ZSog
ZGF0ZSA9IG1zVG9Tb3VwRGF0ZShjb29raWUuZXhwaXJlcyk7CisgICAgICAgIHNvdXBfY29va2ll
X3NldF9leHBpcmVzKHNvdXBDb29raWUsIGRhdGUpOworICAgICAgICBzb3VwX2RhdGVfZnJlZShk
YXRlKTsKKyAgICB9CisgICAgcmV0dXJuIHNvdXBDb29raWU7Cit9CisKK3ZvaWQgYWRkQ29va2ll
KGNvbnN0IE5ldHdvcmtTdG9yYWdlU2Vzc2lvbiYgc2Vzc2lvbiwgY29uc3QgVVJMJiwgY29uc3Qg
Q29va2llJiBjb29raWUpCit7CisgICAgc291cF9jb29raWVfamFyX2FkZF9jb29raWUoY29va2ll
SmFyRm9yU2Vzc2lvbihzZXNzaW9uKSwgdG9Tb3VwQ29va2llKGNvb2tpZSkpOwogfQogCiB2b2lk
IGdldEhvc3RuYW1lc1dpdGhDb29raWVzKGNvbnN0IE5ldHdvcmtTdG9yYWdlU2Vzc2lvbiYgc2Vz
c2lvbiwgSGFzaFNldDxTdHJpbmc+JiBob3N0bmFtZXMpCg==
</data>

          </attachment>
      

    </bug>

</bugzilla>