<?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>231220</bug_id>
          
          <creation_ts>2021-10-05 01:49:17 -0700</creation_ts>
          <short_desc>Clean up shouldAutofocus in HTMLFormControlElement.cpp</short_desc>
          <delta_ts>2021-10-09 01:32:42 -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>DOM</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>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>203139</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Tim Nguyen (:ntim)">ntim</reporter>
          <assigned_to name="Tim Nguyen (:ntim)">ntim</assigned_to>
          <cc>cdumez</cc>
    
    <cc>changseok</cc>
    
    <cc>esprehn+autocc</cc>
    
    <cc>ews-watchlist</cc>
    
    <cc>gyuyoung.kim</cc>
    
    <cc>mifenton</cc>
    
    <cc>rniwa</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1800445</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Nguyen (:ntim)">ntim</who>
    <bug_when>2021-10-05 01:49:17 -0700</bug_when>
    <thetext>Factor out uses of `element-&gt;document()`.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1800448</commentid>
    <comment_count>1</comment_count>
      <attachid>440183</attachid>
    <who name="Tim Nguyen (:ntim)">ntim</who>
    <bug_when>2021-10-05 02:09:05 -0700</bug_when>
    <thetext>Created attachment 440183
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1800450</commentid>
    <comment_count>2</comment_count>
      <attachid>440183</attachid>
    <who name="youenn fablet">youennf</who>
    <bug_when>2021-10-05 02:16:42 -0700</bug_when>
    <thetext>Comment on attachment 440183
Patch

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

&gt; Source/WebCore/html/HTMLFormControlElement.cpp:211
&gt; +    Ref document = element-&gt;document();

Not sure we need to ref it, we are only using document getters, then calling addConsoleMessage and returning.
I would just do auto&amp; document = element-&gt;document();</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1800467</commentid>
    <comment_count>3</comment_count>
      <attachid>440189</attachid>
    <who name="Tim Nguyen (:ntim)">ntim</who>
    <bug_when>2021-10-05 02:47:33 -0700</bug_when>
    <thetext>Created attachment 440189
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1800490</commentid>
    <comment_count>4</comment_count>
    <who name="Tim Nguyen (:ntim)">ntim</who>
    <bug_when>2021-10-05 02:54:48 -0700</bug_when>
    <thetext>Committed r283543 (242508@main): &lt;https://commits.webkit.org/242508@main&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1800491</commentid>
    <comment_count>5</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-10-05 02:55:19 -0700</bug_when>
    <thetext>&lt;rdar://problem/83878528&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1800709</commentid>
    <comment_count>6</comment_count>
      <attachid>440189</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2021-10-05 12:42:31 -0700</bug_when>
    <thetext>Comment on attachment 440189
Patch

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

&gt; Source/WebCore/html/HTMLFormControlElement.cpp:211
&gt; +    auto&amp; document = element.document();

We should store this in Ref.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1801617</commentid>
    <comment_count>7</comment_count>
    <who name="Tim Nguyen (:ntim)">ntim</who>
    <bug_when>2021-10-07 08:52:49 -0700</bug_when>
    <thetext>(In reply to Ryosuke Niwa from comment #6)
&gt; Comment on attachment 440189 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=440189&amp;action=review
&gt; 
&gt; &gt; Source/WebCore/html/HTMLFormControlElement.cpp:211
&gt; &gt; +    auto&amp; document = element.document();
&gt; 
&gt; We should store this in Ref.

See comment 2 by Youenn. Making the argument a `const HTMLFormControlElement&amp;` should be sufficient for safety, but if you think Ref is necessary here, please file a bug and mention why.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1801686</commentid>
    <comment_count>8</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2021-10-07 11:35:16 -0700</bug_when>
    <thetext>(In reply to Tim Nguyen (:ntim) from comment #7)
&gt; (In reply to Ryosuke Niwa from comment #6)
&gt; &gt; Comment on attachment 440189 [details]
&gt; &gt; Patch
&gt; &gt; 
&gt; &gt; View in context:
&gt; &gt; https://bugs.webkit.org/attachment.cgi?id=440189&amp;action=review
&gt; &gt; 
&gt; &gt; &gt; Source/WebCore/html/HTMLFormControlElement.cpp:211
&gt; &gt; &gt; +    auto&amp; document = element.document();
&gt; &gt; 
&gt; &gt; We should store this in Ref.
&gt; 
&gt; See comment 2 by Youenn. Making the argument a `const
&gt; HTMLFormControlElement&amp;` should be sufficient for safety, but if you think
&gt; Ref is necessary here, please file a bug and mention why.

An object being const is no guarantee of safety. There are thousands of const_cast in WebKit.

Also, generally, people who leave code comments like this isn&apos;t responsible for filing a new bug. It&apos;s on you.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1801806</commentid>
    <comment_count>9</comment_count>
    <who name="Tim Nguyen (:ntim)">ntim</who>
    <bug_when>2021-10-07 14:56:30 -0700</bug_when>
    <thetext>(In reply to Ryosuke Niwa from comment #8)
&gt; An object being const is no guarantee of safety. There are thousands of
&gt; const_cast in WebKit.
&gt; 
&gt; Also, generally, people who leave code comments like this isn&apos;t responsible
&gt; for filing a new bug. It&apos;s on you.

I don&apos;t mind filing a bug, though this is against what Youenn said in comment 2 (who told me to use `auto&amp;` instead of `Ref`). Why is `Ref` necessary in this case?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1801840</commentid>
    <comment_count>10</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2021-10-07 16:02:30 -0700</bug_when>
    <thetext>(In reply to Tim Nguyen (:ntim) from comment #9)
&gt; (In reply to Ryosuke Niwa from comment #8)
&gt; &gt; An object being const is no guarantee of safety. There are thousands of
&gt; &gt; const_cast in WebKit.
&gt; &gt; 
&gt; &gt; Also, generally, people who leave code comments like this isn&apos;t responsible
&gt; &gt; for filing a new bug. It&apos;s on you.
&gt; 
&gt; I don&apos;t mind filing a bug, though this is against what Youenn said in
&gt; comment 2 (who told me to use `auto&amp;` instead of `Ref`). Why is `Ref`
&gt; necessary in this case?

Generally, whenever we&apos;re strong a pointer or a reference to a ref counted object in stack, we want to use Ref/RefPtr instead of a raw pointer / raw reference unless we&apos;re only calling trivial functions (e.g. just returning a member variable). See https://lists.webkit.org/pipermail/webkit-dev/2020-September/031386.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1801951</commentid>
    <comment_count>11</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2021-10-08 00:27:54 -0700</bug_when>
    <thetext>(In reply to Ryosuke Niwa from comment #10)
&gt; (In reply to Tim Nguyen (:ntim) from comment #9)
&gt; &gt; (In reply to Ryosuke Niwa from comment #8)
&gt; &gt; &gt; An object being const is no guarantee of safety. There are thousands of
&gt; &gt; &gt; const_cast in WebKit.
&gt; &gt; &gt; 
&gt; &gt; &gt; Also, generally, people who leave code comments like this isn&apos;t responsible
&gt; &gt; &gt; for filing a new bug. It&apos;s on you.
&gt; &gt; 
&gt; &gt; I don&apos;t mind filing a bug, though this is against what Youenn said in
&gt; &gt; comment 2 (who told me to use `auto&amp;` instead of `Ref`). Why is `Ref`
&gt; &gt; necessary in this case?
&gt; 
&gt; Generally, whenever we&apos;re strong a pointer or a reference to a ref counted
&gt; object in stack, we want to use Ref/RefPtr instead of a raw pointer / raw
&gt; reference unless we&apos;re only calling trivial functions (e.g. just returning a
&gt; member variable). See
&gt; https://lists.webkit.org/pipermail/webkit-dev/2020-September/031386.html

I think shouldAutofocus is at the boundary.
It is possible to refactor it to only call trivial getters, the only call (addConsoleMessage) could be moved outside if needed by returning a String error message (addConsoleMesage would be called by shouldAutofocus caller if string is not null).

Also, why refing, if we can just call document() each time, which is probably fast.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1801956</commentid>
    <comment_count>12</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2021-10-08 00:46:58 -0700</bug_when>
    <thetext>(In reply to youenn fablet from comment #11)
&gt; (In reply to Ryosuke Niwa from comment #10)
&gt; &gt; (In reply to Tim Nguyen (:ntim) from comment #9)
&gt; &gt; &gt; (In reply to Ryosuke Niwa from comment #8)
&gt; &gt; &gt; &gt; An object being const is no guarantee of safety. There are thousands of
&gt; &gt; &gt; &gt; const_cast in WebKit.
&gt; &gt; &gt; &gt; 
&gt; &gt; &gt; &gt; Also, generally, people who leave code comments like this isn&apos;t responsible
&gt; &gt; &gt; &gt; for filing a new bug. It&apos;s on you.
&gt; &gt; &gt; 
&gt; &gt; &gt; I don&apos;t mind filing a bug, though this is against what Youenn said in
&gt; &gt; &gt; comment 2 (who told me to use `auto&amp;` instead of `Ref`). Why is `Ref`
&gt; &gt; &gt; necessary in this case?
&gt; &gt; 
&gt; &gt; Generally, whenever we&apos;re strong a pointer or a reference to a ref counted
&gt; &gt; object in stack, we want to use Ref/RefPtr instead of a raw pointer / raw
&gt; &gt; reference unless we&apos;re only calling trivial functions (e.g. just returning a
&gt; &gt; member variable). See
&gt; &gt; https://lists.webkit.org/pipermail/webkit-dev/2020-September/031386.html
&gt; 
&gt; I think shouldAutofocus is at the boundary.

There is no such a thing as &quot;at boundary&quot;. The rule here dictates that we should be strong it in Ref/RefPtr.

&gt; It is possible to refactor it to only call trivial getters, the only call
&gt; (addConsoleMessage) could be moved outside if needed by returning a String
&gt; error message (addConsoleMesage would be called by shouldAutofocus caller if
&gt; string is not null).

Since such a refactoring hasn&apos;t been done, we should just store it in Ref/RefPtr. It&apos;s really not useful to avoid ref-counting like that.

&gt; Also, why refing, if we can just call document() each time, which is
&gt; probably fast.

No, document() dereferences m_treeScope and then has to check whether m_treeScope is a document or not. If a node is inside a shadow tree, then it has to perform a secondary lookup to obtain the document. Also, calling document() each time isn&apos;t safe either because if you&apos;re calling a non-trivial function on Document (or its superclass), then such a non-trivial function could end up invoking some other function (e.g. IPC code) and trigger a synchronous destruction of Document.

Generally, we don&apos;t want everyone who has to modify any code in WebCore to having to reason about what is or what isn&apos;t safe.

Here, instead of contemplating why calling a given function is safe on a document, we should simply keep the document alive longer.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1801982</commentid>
    <comment_count>13</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2021-10-08 03:47:27 -0700</bug_when>
    <thetext>&gt; There is no such a thing as &quot;at boundary&quot;. The rule here dictates that we
&gt; should be strong it in Ref/RefPtr.

There is no use of document after a non-trivial call, that is why I think it is sort of a gray area.

&gt; &gt; It is possible to refactor it to only call trivial getters, the only call
&gt; &gt; (addConsoleMessage) could be moved outside if needed by returning a String
&gt; &gt; error message (addConsoleMesage would be called by shouldAutofocus caller if
&gt; &gt; string is not null).
&gt; 
&gt; Since such a refactoring hasn&apos;t been done, we should just store it in
&gt; Ref/RefPtr. It&apos;s really not useful to avoid ref-counting like that.

I can look at the refactoring, I usually like splitting safe/non mutable code from mutable code.

&gt; &gt; Also, why refing, if we can just call document() each time, which is
&gt; &gt; probably fast.
&gt; 
&gt; No, document() dereferences m_treeScope and then has to check whether
&gt; m_treeScope is a document or not. If a node is inside a shadow tree, then it
&gt; has to perform a secondary lookup to obtain the document.

Quickly looking at the code, I do not see the tree scope check nor the shadow tree specific path.
I might have missed something.

&gt; Also, calling
&gt; document() each time isn&apos;t safe either because if you&apos;re calling a
&gt; non-trivial function on Document (or its superclass), then such a
&gt; non-trivial function could end up invoking some other function (e.g. IPC
&gt; code) and trigger a synchronous destruction of Document.

Agreed but then we have a problem since the expectation is that having a valid element guarantees having a valid document reference.
So we should then ref element as well?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1801989</commentid>
    <comment_count>14</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2021-10-08 04:08:11 -0700</bug_when>
    <thetext>&gt; I can look at the refactoring, I usually like splitting safe/non mutable
&gt; code from mutable code.

I had a try at https://bugs.webkit.org/show_bug.cgi?id=231417</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1802370</commentid>
    <comment_count>15</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2021-10-09 01:32:42 -0700</bug_when>
    <thetext>(In reply to youenn fablet from comment #13)
&gt; &gt; There is no such a thing as &quot;at boundary&quot;. The rule here dictates that we
&gt; &gt; should be strong it in Ref/RefPtr.
&gt; 
&gt; There is no use of document after a non-trivial call, that is why I think it
&gt; is sort of a gray area.

The problem is that this kind of code is fragile. Any future changes to any one of currently trivial functions can introduce a new use-after-free. We don&apos;t want to make WebKit totally unmaintainable by making every function change require a massive audit of every caller as well as every ancestor callers. This immediately results in exponential growth of code to audit, and results either in new use-after-free to be introduced or makes it impossible to make any future code changes. Either option is unacceptable.

&gt; &gt; &gt; It is possible to refactor it to only call trivial getters, the only call
&gt; &gt; &gt; (addConsoleMessage) could be moved outside if needed by returning a String
&gt; &gt; &gt; error message (addConsoleMesage would be called by shouldAutofocus caller if
&gt; &gt; &gt; string is not null).
&gt; &gt; 
&gt; &gt; Since such a refactoring hasn&apos;t been done, we should just store it in
&gt; &gt; Ref/RefPtr. It&apos;s really not useful to avoid ref-counting like that.
&gt; 
&gt; I can look at the refactoring, I usually like splitting safe/non mutable
&gt; code from mutable code.

It doesn&apos;t matter whether such a refactoring is done or not. The above issue withstands regardless.

&gt; &gt; &gt; Also, why refing, if we can just call document() each time, which is
&gt; &gt; &gt; probably fast.
&gt; &gt; 
&gt; &gt; No, document() dereferences m_treeScope and then has to check whether
&gt; &gt; m_treeScope is a document or not. If a node is inside a shadow tree, then it
&gt; &gt; has to perform a secondary lookup to obtain the document.
&gt; 
&gt; Quickly looking at the code, I do not see the tree scope check nor the
&gt; shadow tree specific path.
&gt; I might have missed something.

Node::document is defined as this:

Document&amp; document() const { return treeScope().documentScope(); }
TreeScope&amp; treeScope() const
{
    ASSERT(m_treeScope);
    return *m_treeScope;
}

TreeScope::documentScope is defined as follows:
Document&amp; documentScope() const { return m_documentScope.get(); }

Here, m_documentScope != this when TreeScope is a ShadowRoot.

&gt; &gt; Also, calling
&gt; &gt; document() each time isn&apos;t safe either because if you&apos;re calling a
&gt; &gt; non-trivial function on Document (or its superclass), then such a
&gt; &gt; non-trivial function could end up invoking some other function (e.g. IPC
&gt; &gt; code) and trigger a synchronous destruction of Document.
&gt; 
&gt; Agreed but then we have a problem since the expectation is that having a
&gt; valid element guarantees having a valid document reference.
&gt; So we should then ref element as well?

That&apos;s on the caller. The caller should keep the element alive per rules in https://lists.webkit.org/pipermail/webkit-dev/2020-September/031386.html.

A subtle issue here is that an element can be the last thing keeping this document alive, and if there is any script execution, then that script can adopt this element to another document, making document eligible for deletion.

There are hundreds of subtle object model subtleties like this scattered across WebCore, and most WebKit engineers aren&apos;t familiar with all of them. As such, it&apos;s quite silly to rely on everyone to be aware of them all and carefully remembering to only Ref when it&apos;s absolutely needed.

This is precisely why we&apos;re adopting new rule on how to reply Ref/RefPtr as outlined in https://lists.webkit.org/pipermail/webkit-dev/2020-September/031386.html. Please go talk with Geoff if you have any questions or concerns.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>440183</attachid>
            <date>2021-10-05 02:09:05 -0700</date>
            <delta_ts>2021-10-05 02:47:29 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-231220-20211005110904.patch</filename>
            <type>text/plain</type>
            <size>3393</size>
            <attacher name="Tim Nguyen (:ntim)">ntim</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjgzNTQyCmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggYmViMWI3MjY4ZjVlODk5
N2M5MWZiNzkwNmI2M2RjYmM5MTM5NjkwZC4uYzIxOTQyOGQ4OGI4NzVmOGY3NjkzNDU0NjZmMWQ1
ODMwM2I3YzAwMiAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE5IEBACisyMDIxLTEwLTA1ICBUaW0g
Tmd1eWVuICA8bnRpbUBhcHBsZS5jb20+CisKKyAgICAgICAgQ2xlYW4gdXAgc2hvdWxkQXV0b2Zv
Y3VzIGluIEhUTUxGb3JtQ29udHJvbEVsZW1lbnQuY3BwCisgICAgICAgIGh0dHBzOi8vYnVncy53
ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD0yMzEyMjAKKworICAgICAgICBSZXZpZXdlZCBieSBO
T0JPRFkgKE9PUFMhKS4KKworICAgICAgICBObyBiZWhhdmlvdXIgY2hhbmdlLgorCisgICAgICAg
IE1pbm9yIGNsZWFudXBzOgorICAgICAgICAtIENsZWFuIHVwIHJlcGVhdGVkIGNhbGxzIG9mIGVs
ZW1lbnQtPmRvY3VtZW50KCkKKyAgICAgICAgLSBVc2UgdG9wT3JpZ2lu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2VjdXJpdHksIE1lc3NhZ2VMZXZlbDo6RXJyb3IsICJCbG9ja2Vk
IGF1dG9mb2N1c2luZyBvbiBhIGZvcm0gY29udHJvbCBpbiBhIGNyb3NzLW9yaWdpbiBzdWJmcmFt
ZS4iX3MpOworICAgIGlmICghZG9jdW1lbnQtPmZyYW1lKCktPmlzTWFpbkZyYW1lKCkgJiYgIWRv
Y3VtZW50LT50b3BPcmlnaW4oKS5pc1NhbWVPcmlnaW5Eb21haW4oZG9jdW1lbnQtPnNlY3VyaXR5
T3JpZ2luKCkpKSB7CisgICAgICAgIGRvY3VtZW50LT5hZGRDb25zb2xlTWVzc2FnZShNZXNzYWdl
U291cmNlOjpTZWN1cml0eSwgTWVzc2FnZUxldmVsOjpFcnJvciwgIkJsb2NrZWQgYXV0b2ZvY3Vz
aW5nIG9uIGEgZm9ybSBjb250cm9sIGluIGEgY3Jvc3Mtb3JpZ2luIHN1YmZyYW1lLiJfcyk7CiAg
ICAgICAgIHJldHVybiBmYWxzZTsKICAgICB9CiAK
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>440189</attachid>
            <date>2021-10-05 02:47:33 -0700</date>
            <delta_ts>2021-10-05 02:47:33 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-231220-20211005114732.patch</filename>
            <type>text/plain</type>
            <size>5729</size>
            <attacher name="Tim Nguyen (:ntim)">ntim</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjgzNTQyCmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggYmViMWI3MjY4ZjVlODk5
N2M5MWZiNzkwNmI2M2RjYmM5MTM5NjkwZC4uZWVhMmE2MTkxZDQ4YWEyZThmZGI0MzU4YjMxODdi
MDkxM2ZkM2ZlNSAxMDA2NDQKLS0tIGEvU291cmNlL1dlY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