Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP Notice in OutputRules #115

Merged
merged 2 commits into from
Sep 22, 2016

Conversation

downsider
Copy link
Contributor

When outputting a TEXT_RAW node, OutputRules will occasionally throw the PHP Notice Undefined property: DOMElement::$data.

This seems to happen when processing HTML that doesn't strictly conform to spec (my test case had child nodes inside an iframe), however we can prevent the issue by type checking the node before accessing the data property

@goetas
Copy link
Member

goetas commented Aug 17, 2016

can you add a test for it?

@downsider
Copy link
Contributor Author

Sure, have done.

Turns out I was slightly wrong in my assumption about the HTML not conforming to spec. I found out that it was manipulation of the DOM that was causing the issue; appending a non-text child node to a TEXT_RAW element after the HTML had been parsed

Are you sure this should be tagged as an enhancement? I'd call it a bugfix more than anything else.

@goetas
Copy link
Member

goetas commented Aug 19, 2016

This issue gets more interesting.
I'm not sure about the final behavior, and it will break many things.
The behavior you have implemented strip silently information.

Immagine this (a mustache.js template):

<html lang="en" id="base">
    <body>
       <script id="template" type="x-tmpl-mustache">
           <h1>Hello {{ name }}!</h1>
          </script>
    </body>
</html>

Adding a <p>foo</p> looks perfectly reasonable and the expected output should be:

<html lang="en" id="base">
    <body>
       <script id="template" type="x-tmpl-mustache">
           <h1>Hello {{ name }}!</h1>
          <p>foo</p></script>
    </body>
</html>

While with your changes will just be ignored

goetas added a commit that referenced this pull request Aug 19, 2016
goetas added a commit that referenced this pull request Aug 19, 2016
goetas added a commit that referenced this pull request Aug 19, 2016
@goetas
Copy link
Member

goetas commented Aug 19, 2016

#117 is and alternative solution

@goetas goetas added the bug label Aug 19, 2016
@goetas goetas merged commit 4c3a923 into Masterminds:2.x Sep 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants