Skip to content

the tree builder will modify the original doc's dom structure when encounters a foreign tag that it doesn't expect #694

@edenw97

Description

@edenw97

The issue is found when test against wpt test: https://wpt.live//mathml/presentation-markup/mrow/semantics-003.html
Original:

  <p>
      annotation-xml 5: 
      <math>
          <semantics>
              <csymbol>Content MathML</csymbol>
              <annotation-xml encoding="application/xhtml+xml">
                  <html xmlns="http://www.w3.org/1999/xhtml">
                      <head>
                          <title>application/xhtml+xml</title>
                      </head>
                      <body>
                          <p>application/xhtml+xml</p>
                      </body>
                  </html>
              </annotation-xml>
              <annotation-xml encoding="application/mathml-presentation+xml">
                  <mtext>error</mtext>
              </annotation-xml>
              <annotation>error</annotation>
      </math>
  </p>
  <p>
      annotation-xml 6: 
      <math>
          <semantics>
              <csymbol>Content MathML</csymbol>
              <annotation-xml encoding="text/html">
                  <html>
                      <head>
                          <title>text/html</title>
                      </head>
                      <body>
                          <p>text/html</p>
                      </body>
                  </html>
              </annotation-xml>
              <annotation-xml encoding="application/mathml-presentation+xml">
                  <mtext>error</mtext>
              </annotation-xml>
              <annotation>error</annotation>
          </semantics>
      </math>
  </p>

rcdom's html2html output

<p>
    annotation-xml 5: 
    <math>
        <semantics>
            <csymbol>Content MathML</csymbol>
            <annotation-xml encoding="application/xhtml+xml">
                
                    
                        <title>application/xhtml+xml</title>
                    
                    
                        </annotation-xml></semantics></math></p><p>application/xhtml+xml</p>
                    
                
            
            <annotation-xml encoding="application/mathml-presentation+xml">
                <mtext>error</mtext>
            </annotation-xml>
            <annotation>error</annotation>
    
<p></p>
<p>
    annotation-xml 6: 
    <math>
        <semantics>
            <csymbol>Content MathML</csymbol>
            <annotation-xml encoding="text/html">
                
                    
                        <title>text/html</title>
                    
                    
                        </annotation-xml></semantics></math></p><p>text/html</p>
                    
                
            
            <annotation-xml encoding="application/mathml-presentation+xml">
                <mtext>error</mtext>
            </annotation-xml>
            <annotation>error</annotation>
        
    
<p></p>

The root cause looks to be that the tag is unexpected in the foreign content and the following function pop out the scope https://github.com/servo/html5ever/blob/main/html5ever/src/tree_builder/mod.rs#L1834

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions