变更集58040
图例:
未修改 补充 远离的
-
trunk/src/wp-includes/html-api/class-wp-html-tag-processor.php 57987兰特 58040兰特 1630 1630 * https://html.spec.whatwg.org/multipage/parsing.html#标记 -声明打开状态 1631 1631 */ 1632 如果( '!' === $ html[$在+1处]){ 1632 如果( ! $ 此->是关闭标记&& '!' === $ html[$在+1处]){ 1633 1633 /* 1634 1634 * `<!--` 转换到注释状态&应用进一步的注释规则。 … … 1810 1810 */ 1811 1811 if('>'===$html[$at+1]){ 1812 //`<>`被解释为纯文本。 1813 if(!$this->is_closingtag){ 1814 ++$在; 1815 继续; 1816 } 1817 1812 1818 $this->parser_state=self::state_PRESUMPTUOUS_TAG; 1813 1819 $this->token_length=$at+2-$this->token_starts_at; … … 1820 1826 *请参阅 https://html.spec.whatwg.org/multipage/parsing.html#tag -开放状态 1821 1827 */ 1822 如果( '?' === $ html[$在+1处]){ 1828 如果( ! $ 此->是关闭标记&& '?' === $ html[$在+1处]){ 1823 1829 $closer_at=strpos($html,'>',$at+2); 1824 1830 if(false===$closer_at){ … … 1892 1898 } 1893 1899 1894 $closer_at=strpos($html,'>',$at+ 三 ); 1900 $closer_at=strpos($html,'>',$at+ 2 ); 1895 1901 if(false===$closer_at){ 1896 1902 $this->parser_state=self::state_INCOMPLETE_INPUT; -
trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor-token-scanning.php 57508兰特 58040兰特 762 762 763 763 /** 764 *确保正确解析各种时髦的评论。 765 * 766 *@票60170 767 * 768 *@自6.6.0起 769 * 770 *@covers WP_HTML_Tag_Processor::next_token 771 * 772 *@dataProvider data_various_funky_comments 773 * 774 *@param string$funky_comment_html html包含一个时髦的注释。 775 *@param string$modifable_text HTML中第一条funky注释的可修改文本。 776 */ 777 公共函数test_various_funky_comments($funky注释html,$modifable_text){ 778 $processor=新的WP_HTML_Tag_processor($funky_comment_HTML); 779 while('#funky-comment'!==$processor->get_token_type()&&$process->next_token()){ 780 继续; 781 } 782 783 $this->资产相同( 784 “#funky-comment”, 785 $processor->get_token_type(), 786 “找不到预期的时髦评论。” 787 ); 788 789 $this->资产相同( 790 $modifable_text, 791 $processor->get_modifable_text(), 792 “在一个古怪的评论中发现了错误的可修改文本跨度。” 793 ); 794 } 795 796 /** 797 *数据提供商。 798 * 799 *@return数组[]。 800 */ 801 公共静态函数data_various_funky_comments(){ 802 返回数组( 803 “空格”=>数组(“</>”,“”), 804 '短带'=>数组('</!>','!'), 805 “问号”=>数组(“</?>”,“?”), 806 “短斜杠”=>数组(“<//>”,“/”), 807 “位(无属性)”=>数组(“<//wp:post-meta>”,“/wp:post-meta”), 808 “位(属性)”=>数组(“<//wp:post-meta-key=isbn>”,“/wp:post-meta-key=isbn”), 809 “卷曲”=>数组(“</{json}>”,“{json{”), 810 '在P'=>数组之前('</1><P>','1'), 811 '在P'=>数组之后('<P></__(“阅读更多”)></P>','__(“读取更多”)'), 812 “引用”=>数组(“</>;>”,“>;”), 813 ); 814 } 815 816 /** 764 817 *用双引号包装字符串的测试助手。 765 818 * -
trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPI.php 57987兰特 58040兰特 589 589 * 590 590 *@covers::process_directives 591 */ 592 公共函数test_process_directives_doesnt_change_html_if_contains_unbalanced_tags(){ 591 * 592 *@dataProvider data_html_with_unbalanced_tags 593 * 594 *@param string$html html包含不平衡标记和指令。 595 */ 596 公共函数test_process_directives_doesnt_change_html_if_contains_unbalanced_tags($html){ 593 597 $this->interactivity->state(“myPlugin”,数组(“id”=>“some-id”)); 594 598 595 $html_samples=数组( 596 '<div data-wp-bind--id=“myPlugin::state.id”>内部内容</div></div>', 597 '<div data-wp-bind--id=“myPlugin::state.id”>内部内容</div><div>', 598 '<div><div data-wp-bind--id=“myPlugin::state.id”>内部内容</div>', 599 '</div><div data-wp-bind--id=“myPlugin::state.id”>内部内容</div>', 600 '<div data-wp-bind--id=“myPlugin::state.id”>内部<div>内容</div>', 601 '<div data-wp-bind--id=“myPlugin::state.id”>内部</div>内容</div>', 602 '<div data-wp-bind--id=“myPlugin::state.id”><span>内部内容</div>', 603 '<div data-wp-bind--id=“myPlugin::state.id”>内部内容</div></span>', 604 '<div data-wp-bind--id=“myPlugin::state.id”><span>内部内容</div></span>', 605 '<div data-wp-bind--id=“myPlugin::state.id”>内部连接</></div>', 606 ); 607 608 foreach($html_samples作为$html){ 609 $processed_html=$this->interactivity->process_directives($html); 610 $p=新的WP_HTML_Tag_Processor($processed_HTML); 611 $p->next_tag(); 612 $this->assertNull($p->get_attribute('id')); 613 } 599 $processed_html=$this->interactivity->process_directives($html); 600 $p=新的WP_HTML_Tag_Processor($processed_HTML); 601 $p->next_tag(); 602 $this->assertNull($p->get_attribute('id')); 603 } 604 605 /** 606 *数据提供商。 607 * 608 *@返回数组[]。 609 */ 610 公共静态函数data_html_with_unbalanced_tags(){ 611 返回数组( 612 'DIV closer after'=>数组('<DIV data-wp-bind--id=“myPlugin::state.id”>内部内容</DIV></DIV>'), 613 'DIV opener after'=>array('<DIV data-wp-bind--id=“myPlugin::state.id”>内部内容</DIV><DIV>'), 614 'DIV opener before'=>数组('<DIV><DIV data-wp-bind--id=“myPlugin::state.id”>内部内容</DIV>'), 615 'DIV closer before'=>数组('</DIV><DIV data-wp-bind--id=“myPlugin::state.id”>内部内容</DIV>), 616 'DIV opener inhere'=>数组('<DIV data-wp-bind--id=“myPlugin::state.id”>内部<DIV>内容</DIV>'), 617 'DIV closer inside'=>数组('<DIV data-wp-bind--id=“myPlugin::state.id”>内部</DIV>内容</DIV>'), 618 “SPAN opener inside”=>数组('<div data-wp-bind--id=“myPlugin::state.id”><SPAN>内部内容</div>'), 619 'SPAN closer after'=>array('<div data-wp-bind--id=“myPlugin::state.id”>内部内容</div></SPAN>'), 620 'SPAN重叠'=>数组('<div data wp-bind--id=“myPlugin::state.id”><SPAN>内部内容</div></SPAN>'), 621 ); 614 622 } 615 623