<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>37395</bug_id>
          
          <creation_ts>2019-10-29 17:58:38 +0300</creation_ts>
          <short_desc>Игнорирует XML_PARSE_NOERROR и XML_PARSE_NOWARNING в парсере html</short_desc>
          <delta_ts>2019-11-01 19:58:05 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>libxml2</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>https://bugzilla.gnome.org/show_bug.cgi?id=638618</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Anton Farygin">rider</reporter>
          <assigned_to name="Dmitry V. Levin">ldv</assigned_to>
          <cc>maks1ms</cc>
    
    <cc>rider</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>185170</commentid>
    <comment_count>0</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2019-10-29 17:58:38 +0300</bug_when>
    <thetext>Игнорирует LIBXML_NOWARNING и LIBXML_NOERROR в парсере html для случаев, когда используется xmlGenericError handler.

Коммит 4b023ad2a90ca89e8dec7dd8f4558ff4c94f771a приводит к тому, что не проходит тест ошибки 74004 в PHP. А именно - установка LIBXML_NOERROR должна глушить вывод ошибок libxml.

в других дистрибутивах тест проходит.

тест выглядит так:
$doc=new DOMDocument();
$doc-&gt;loadHTML(&quot;&lt;tag-throw&gt;&lt;/tag-throw&gt;&quot;,LIBXML_NOERROR);

В результате теста у нас вывод:
Warning: DOMDocument::loadHTML(): Tag tag-throw invalid in /usr/src/RPM/BUILD/php7-source/ext/dom/tests/bug74004.php on line 4
===DONE===

в других дистрибутивах Warning глушится.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185176</commentid>
    <comment_count>1</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2019-10-29 19:28:22 +0300</bug_when>
    <thetext>libxml2$ git grep -Fw LIBXML_NOERROR |wc -l
0
libxml2$ git grep -Fw LIBXML_NOWARNING |wc -l
0

Уточните, пожалуйста, о каких именно NOERROR и NOWARNING идёт речь.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185179</commentid>
    <comment_count>2</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2019-10-29 20:08:12 +0300</bug_when>
    <thetext>Да, прошу прощения. Названия из php, в libxml2 это
XML_PARSE_NOERROR и XML_PARSE_NOWARNING</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185187</commentid>
    <comment_count>3</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2019-10-30 08:23:25 +0300</bug_when>
    <thetext>Т.е. - у нас приложен патч:
https://bug638618.bugzilla-attachments.gnome.org/attachment.cgi?id=181851

Но при этом поведение по умолчанию всё-таки изменилось и привело к тому, что вылез этот баг в php, когда вызывается callback на xmlGenericError (который и приводит к выводу Warning там, где его не ждут).

В апстриме resolved fixed, но у нас в этом месте код другой.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185190</commentid>
    <comment_count>4</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2019-10-30 11:30:40 +0300</bug_when>
    <thetext>(In reply to comment #3)
&gt; Т.е. - у нас приложен патч:
&gt; https://bug638618.bugzilla-attachments.gnome.org/attachment.cgi?id=181851

Это в точности дополнительный коммит 4b023ad2a90ca89e8dec7dd8f4558ff4c94f771a, который не попал в апстримный git.

&gt; Но при этом поведение по умолчанию всё-таки изменилось и привело к тому, что
&gt; вылез этот баг в php, когда вызывается callback на xmlGenericError (который и
&gt; приводит к выводу Warning там, где его не ждут).

Да, это очень похоже на &quot;If sax context is set but sax context callback channel is not set, fall back to use xmlGenericError, otherwise the error will be lost.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185191</commentid>
    <comment_count>5</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2019-10-30 11:47:00 +0300</bug_when>
    <thetext>Ещё в разнице в выводе ошибок между нами и версией в debian (такой же) замечена ошибка про структуру XML Reference not found, которая у нас появляется, а у Debian нет

Выглядит это так (у нас):

$  /usr/src/RPM/BUILD/php7-source/sapi/cli/php  -n -c &apos;/usr/src/RPM/BUILD/php7-source/tmp-php.ini&apos;  -d &quot;output_handler=&quot; -d &quot;open_basedir=&quot; -d &quot;disable_functions=&quot; -d &quot;output_buffering=Off&quot; -d &quot;error_reporting=32767&quot; -d &quot;display_errors=1&quot; -d &quot;display_startup_errors=1&quot; -d &quot;log_errors=0&quot; -d &quot;html_errors=0&quot; -d &quot;track_errors=0&quot; -d &quot;report_memleaks=1&quot; -d &quot;report_zend_debug=0&quot; -d &quot;docref_root=&quot; -d &quot;docref_ext=.html&quot; -d &quot;error_prepend_string=&quot; -d &quot;error_append_string=&quot; -d &quot;auto_prepend_file=&quot; -d &quot;auto_append_file=&quot; -d &quot;ignore_repeated_errors=0&quot; -d &quot;precision=14&quot; -d &quot;memory_limit=128M&quot; -d &quot;log_errors_max_len=0&quot; -d &quot;opcache.fast_shutdown=0&quot; -d &quot;opcache.file_update_protection=0&quot; -d &quot;zend.assertions=1&quot; -d &quot;extension_dir=/usr/src/RPM/BUILD/php7-source/modules/&quot; -d &quot;extension=mysqlnd.so&quot; -d &quot;session.auto_start=0&quot; -d &quot;zlib.output_compression=Off&quot; -f &quot;/usr/src/RPM/BUILD/php7-source/ext/xml/tests/xml004.php&quot;

Warning: xml_parse(): PEReference: %incent; not found in /usr/src/RPM/BUILD/php7-source/ext/xml/tests/xml004.php on line 8
&lt;root id=&quot;elem1&quot;&gt;
&lt;elem1&gt;
&lt;elem2&gt;
&lt;elem3&gt;

Warning: xml_parse(): Entity &apos;included-entity&apos; not defined in /usr/src/RPM/BUILD/php7-source/ext/xml/tests/xml004.php on line 8
&lt;elem4&gt;
&lt;/elem4&gt;
&lt;/elem3&gt;
&lt;/elem2&gt;
&lt;/elem1&gt;
&lt;/root&gt;

Warning: xml_parse(): PEReference: %incent; not found in /usr/src/RPM/BUILD/php7-source/ext/xml/tests/xml004.php on line 16
&lt;ROOT ID=&quot;elem1&quot;&gt;
&lt;ELEM1&gt;
&lt;ELEM2&gt;
&lt;ELEM3&gt;

Warning: xml_parse(): Entity &apos;included-entity&apos; not defined in /usr/src/RPM/BUILD/php7-source/ext/xml/tests/xml004.php on line 16
&lt;ELEM4&gt;
&lt;/ELEM4&gt;
&lt;/ELEM3&gt;
&lt;/ELEM2&gt;
&lt;/ELEM1&gt;
&lt;/ROOT&gt;


В Debian:

test@debian:~$ cat xmltest.xml 
&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;
&lt;!DOCTYPE phptest SYSTEM &quot;notfound.dtd&quot; [
&lt;!ENTITY % incent SYSTEM &quot;inc.ent&quot;&gt;
%incent;
]&gt;
&lt;root id=&quot;elem1&quot;&gt;
 Plain text.
 &lt;elem1&gt;
  &lt;!-- comment --&gt;
  &lt;elem2&gt;
   &lt;![CDATA[CDATA block]]&gt;
   &lt;elem3&gt;
    &amp;included-entity;
    &lt;elem4&gt;
     &lt;?test processing instruction ?&gt;
    &lt;/elem4&gt;
   &lt;/elem3&gt;
  &lt;/elem2&gt;
 &lt;/elem1&gt;
&lt;/root&gt;

код:
$ php
&lt;?php
chdir(dirname(__FILE__));
$xp = xml_parser_create();
xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false);
xml_set_element_handler($xp, &quot;start_element&quot;, &quot;end_element&quot;);
$fp = fopen(&quot;xmltest.xml&quot;, &quot;r&quot;);
while ($data = fread($fp, 4096)) {
        xml_parse($xp, $data, feof($fp));
}
xml_parser_free($xp);
$xp = xml_parser_create();
xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, true);
xml_set_element_handler($xp, &quot;start_element&quot;, &quot;end_element&quot;);
$fp = fopen(&quot;xmltest.xml&quot;, &quot;r&quot;);
while ($data = fread($fp, 4096)) {
        xml_parse($xp, $data, feof($fp));
}
xml_parser_free($xp);

function start_element($xp, $elem, $attribs)
{
        print &quot;&lt;$elem&quot;;
        if (sizeof($attribs)) {
        foreach ($attribs as $k =&gt; $v) {
                        print &quot; $k=\&quot;$v\&quot;&quot;;
                }
        }
        print &quot;&gt;\n&quot;;
}

function end_element($xp, $elem)
{
        print &quot;&lt;/$elem&gt;\n&quot;;
}
?&gt;

Вывод:

&lt;root id=&quot;elem1&quot;&gt;
&lt;elem1&gt;
&lt;elem2&gt;
&lt;elem3&gt;
&lt;elem4&gt;
&lt;/elem4&gt;
&lt;/elem3&gt;
&lt;/elem2&gt;
&lt;/elem1&gt;
&lt;/root&gt;
&lt;ROOT ID=&quot;elem1&quot;&gt;
&lt;ELEM1&gt;
&lt;ELEM2&gt;
&lt;ELEM3&gt;
&lt;ELEM4&gt;
&lt;/ELEM4&gt;
&lt;/ELEM3&gt;
&lt;/ELEM2&gt;
&lt;/ELEM1&gt;
&lt;/ROOT&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185192</commentid>
    <comment_count>6</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2019-10-30 11:57:14 +0300</bug_when>
    <thetext>(В ответ на комментарий №4)
&gt; (In reply to comment #3)

&gt; 
&gt; &gt; Но при этом поведение по умолчанию всё-таки изменилось и привело к тому, что
&gt; &gt; вылез этот баг в php, когда вызывается callback на xmlGenericError (который и
&gt; &gt; приводит к выводу Warning там, где его не ждут).
&gt; 
&gt; Да, это очень похоже на &quot;If sax context is set but sax context callback channel
&gt; is not set, fall back to use xmlGenericError, otherwise the error will be
&gt; lost.&quot;

Мне кажется, что его надо доработать так, что бы он учитывал флаги XML_PARSE_NOERROR и XML_PARSE_NOWARNING. Т.е. - если контекст sax есть, но при этом у него handler&apos;ов на warning и error нету - то не переключаться на xmlGenericError.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185194</commentid>
    <comment_count>7</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2019-10-30 12:40:47 +0300</bug_when>
    <thetext>(In reply to comment #6)
&gt; (В ответ на комментарий №4)
&gt; &gt; (In reply to comment #3)
&gt; 
&gt; &gt; 
&gt; &gt; &gt; Но при этом поведение по умолчанию всё-таки изменилось и привело к тому, что
&gt; &gt; &gt; вылез этот баг в php, когда вызывается callback на xmlGenericError (который и
&gt; &gt; &gt; приводит к выводу Warning там, где его не ждут).
&gt; &gt; 
&gt; &gt; Да, это очень похоже на &quot;If sax context is set but sax context callback channel
&gt; &gt; is not set, fall back to use xmlGenericError, otherwise the error will be
&gt; &gt; lost.&quot;
&gt; 
&gt; Мне кажется, что его надо доработать так, что бы он учитывал флаги
&gt; XML_PARSE_NOERROR и XML_PARSE_NOWARNING. Т.е. - если контекст sax есть, но при
&gt; этом у него handler&apos;ов на warning и error нету - то не переключаться на
&gt; xmlGenericError.

Другими словами, ты предлагаешь откатить ту часть коммита, описание которой я процитировал, потому что она вызывает регрессию.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185196</commentid>
    <comment_count>8</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2019-10-30 13:55:26 +0300</bug_when>
    <thetext>(В ответ на комментарий №7)
&gt; (In reply to comment #6)
&gt; &gt; (В ответ на комментарий №4)
&gt; &gt; &gt; (In reply to comment #3)
&gt; &gt; 
&gt; &gt; &gt; 
&gt; &gt; &gt; &gt; Но при этом поведение по умолчанию всё-таки изменилось и привело к тому, что
&gt; &gt; &gt; &gt; вылез этот баг в php, когда вызывается callback на xmlGenericError (который и
&gt; &gt; &gt; &gt; приводит к выводу Warning там, где его не ждут).
&gt; &gt; &gt; 
&gt; &gt; &gt; Да, это очень похоже на &quot;If sax context is set but sax context callback channel
&gt; &gt; &gt; is not set, fall back to use xmlGenericError, otherwise the error will be
&gt; &gt; &gt; lost.&quot;
&gt; &gt; 
&gt; &gt; Мне кажется, что его надо доработать так, что бы он учитывал флаги
&gt; &gt; XML_PARSE_NOERROR и XML_PARSE_NOWARNING. Т.е. - если контекст sax есть, но при
&gt; &gt; этом у него handler&apos;ов на warning и error нету - то не переключаться на
&gt; &gt; xmlGenericError.
&gt; 
&gt; Другими словами, ты предлагаешь откатить ту часть коммита, описание которой я
&gt; процитировал, потому что она вызывает регрессию.

Да, всё верно.

Надо бы ещё понять каким образом этот коммит влияет на дополнительно вылезший вывод ошибок с разбором структуры XML документа.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185197</commentid>
    <comment_count>9</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2019-10-30 14:29:27 +0300</bug_when>
    <thetext>На самом деле в php из-за таких ошибок, которые отсутствуют в других системах а есть только у нас и касаются качества подаваемого на вход XML - не проходит не один, а 5 тестов на libxml.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185211</commentid>
    <comment_count>10</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2019-10-31 11:56:15 +0300</bug_when>
    <thetext>после отката error.c в libxml2 к текущему апстримному виду - все тесты, связанные с libxml в php стали проходить без дополнительных исправлений.
testStructuredErrorFunc тоже не падает.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185212</commentid>
    <comment_count>11</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2019-10-31 12:29:48 +0300</bug_when>
    <thetext>(In reply to comment #10)
&gt; после отката error.c в libxml2 к текущему апстримному виду - все тесты,
&gt; связанные с libxml в php стали проходить без дополнительных исправлений.
&gt; testStructuredErrorFunc тоже не падает.

В error.c никаких других изменений, помимо того дополнительного коммита 4b023ad2a90ca89e8dec7dd8f4558ff4c94f771a, уже давно нет.
Если реверт этого коммита не вызывает регрессий в testStructuredErrorFunc,
предлагаю отревертить.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185214</commentid>
    <comment_count>12</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2019-10-31 14:27:08 +0300</bug_when>
    <thetext>Ну ок. Я не против. Ментейнера попросим ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185270</commentid>
    <comment_count>13</comment_count>
    <who name="Alexey Shabalin">shaba</who>
    <bug_when>2019-11-01 19:57:30 +0300</bug_when>
    <thetext>Исправлено в libxml2-2.9.10-alt1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>185271</commentid>
    <comment_count>14</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2019-11-01 19:58:05 +0300</bug_when>
    <thetext>спасибо.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>