trailofbits / trailofbits/graphtage

Text missing from HTML diff

Open
#80 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.5k
Forks
61
Avg merge
6h 45m
Merged PRs (30d)
45

Description

When using the following test HTML files as input...

$ cat old.html
<html>
        <body>
                some <div>text and more</div> text
        </body>
</html>

$ cat new.html
<html>
        <body>
                some <div class='red'>text</div> and more <strong>text</strong>
        </body>
</html>

$ graphtage old.html new.html
<html>
        <body>
                some <̟d̟i̟v̟ ̟c̟l̟a̟s̟s̟=̟"̟r̟e̟d̟"̟>̟t̟e̟x̟t̟<̟/̟d̟i̟v̟>̟
        <̟s̟t̟r̟o̟n̟g̟>̟t̟e̟x̟t̟<̟/̟s̟t̟r̟o̟n̟g̟>̟
        <̶d̶i̶v̶>̶t̶e̶x̶t̶ ̶a̶n̶d̶ ̶m̶o̶r̶e̶<̶/̶d̶i̶v̶>̶
    </body>
</html>

+ screenshot:
image

..., as you can see, the text and more is missing from the diff generated by graphtage.

I've tried some other diff tools and it seems and none of them had any success with correctly processing these two files for some reason (many are using the same core algorithm I suppose). Is there some kind of general issue with processing text not enclosed in tags (as in, and more is between two elements, but not enclosed in any tag (apart from the parent <body> tag) itself)?

I have also tried surrounding and more in a <p> tag in new.html, which resulted in this mess:

$ graphtage old.html new.html
<html>
        <body>
                some <̟d̟i̟v̟ ̟c̟l̟a̟s̟s̟=̟"̟r̟e̟d̟"̟>̟t̟e̟x̟t̟<̟/̟d̟i̟v̟>̟
        <p̟d̶i̶v̶>t̶e̶x̶t̶ ̶and more</p̟d̶i̶v̶>
        <̟s̟t̟r̟o̟n̟g̟>̟t̟e̟x̟t̟<̟/̟s̟t̟r̟o̟n̟g̟>̟
    </body>
</html>

+ screenshot:
image

What's happening?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with the shown old.html and new.html files by running graphtage old.html new.html. Trace how the HTML diff represents text between elements and compare both examples; done means the generated diff preserves and more and handles the paragraph variant without corrupting the markup.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, python
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.