Bug in src/parser/html/PhutilDOMNode.php

PhutilDOMNode is trying to invoke nonexistent method setRawContent. Fix is simple, it should call setRawString instead.


git diff src/parser/html/PhutilDOMNode.php
diff --git a/src/parser/html/PhutilDOMNode.php b/src/parser/html/PhutilDOMNode.php
index 5b87ae3..9a5130d 100644
--- a/src/parser/html/PhutilDOMNode.php
+++ b/src/parser/html/PhutilDOMNode.php
@@ -113,7 +113,7 @@ final class PhutilDOMNode extends Phobject {
       $nodes[] = id(new self())
-        ->setRawContent($raw_content);
+        ->setRawString($raw_content);
     return $this->mergeContentNodes($nodes);


    4c242256e490bd9c7e865137dd345287696f0cff (Sat, Jun 29) 
    feb5f4d42c4fe0001e76428e80d5e88262308802 (Sat, Jun 22) 
    a4feaf52f4c01ff692e46e53bb731c9d7e5bedfe (Sat, Jun 29) 
    3.6 at /bin/diff 
    2.20.1 at /bin/git 
    Not Available 
    2.2.0 at /bin/pygmentize 
    Not Available 

Bug can be reproduced in phriction documents (Exeption is thrown).

I can’t reproduce this. Here’s what I did:

  • Viewed an empty Phriction document.

The page loaded correctly.

Unfortunately, it’s a bit difficult to reproduce, as when fix is applied (which I have), even reverting to previous code doesn’t reproduce the issue.

However, by simple inspection it can be seen that setRawContent method doesn’t exist in given class (nor within parent).

I’m not quite sure in which cases is selectChildrenWithTags invoked, or going through the path.

Anyhow, here’s a screenshot of exception:

The problem is likely to be a malformed or unusual <table> tag in Remarkup.

You can usually reproduce parsing errors by running bin/cache purge --caches remarkup, then reloading the page.

The simplest way to generate a reproduction case is probably to take whatever <table> tags exist in the document and plug them into a comment in another application like Maniphest. If the tag works, you’ll get a preview. If you hit the bug, you’ll get an exception or a broken preview + exception in the logs. You can use this technique in general by copy/pasting the whole document to start with, then deleting parts of it. You can force the cache to dirty by typing random text somewhere in the document.

The reproduction case probably looks like <table>... with some unusually positioned content or uneven tags. To fix this, I’d like to first add test coverage for the problem, and I need a reproduction case to be able to do that.

Here’s the input to reproduce the bug:

<tr><td>text < text</td></tr>


https://secure.phabricator.com/D20630 should fix the fatal.

https://secure.phabricator.com/D20631 should improve how we interpret input in the form <td><</td>.

1 Like