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

Elements are mistakenly selected in template HTML #13

Open
Web-Distortion opened this issue Mar 30, 2022 · 0 comments
Open

Elements are mistakenly selected in template HTML #13

Web-Distortion opened this issue Mar 30, 2022 · 0 comments

Comments

@Web-Distortion
Copy link

The following example shows a case where elements are mistakenly selected and manulated in template HTMLs, causing visual distortion.

As shown in the following codes, compared with v0, another <a href="https://www.youtube.com">youtube</a> element is added to the <body> in v1 of the HTML, and thus changes the indices of <body>'s children. However, the scripts are temeplated and can't detect and react to such a change.
As a result, the <div>afterend</div> is inserted at a wrong position in the Fawkes page: it is inserted after the <a href="https://www.gmail.com">gmail</a> tag, rather the <a href="https://www.youtube.com">youtube</a> tag in the original v1 page.

<!-- v0 -->
<!DOCTYPE html>
<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <a href="https://www.google.com">google</a>
        <!-- <a href="https://www.youtube.com">youtube</a> -->
        <a href="https://www.gmail.com">gmail</a>
    </body>

    <script type="text/javascript">
        var div = document.createElement('div')
        div.innerText = 'afterend'
        var before = document.body.children[1];
    </script>

    <script type="text/javascript">
        before.insertAdjacentElement('afterend', div);
    </script>
</html>

<!-- v1 -->
<!DOCTYPE html>
<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <a href="https://www.google.com">google</a>
        <a href="https://www.youtube.com">youtube</a>
        <a href="https://www.gmail.com">gmail</a>
    </body>

    <script type="text/javascript">
        var div = document.createElement('div')
        div.innerText = 'afterend'
        var before = document.body.children[1];
    </script>

    <script type="text/javascript">
        before.insertAdjacentElement('afterend', div);
    </script>
</html>

<!-- templates -->
<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <a href="https://www.google.com">google</a>
        <a href="https://www.gmail.com">gmail</a>
        <script type="text/javascript">
            var div = document.createElement('div')
            div.innerText = 'afterend'
            var before = document.body.children[1];
        </script>
        <script type="text/javascript">
            before.insertAdjacentElement('afterend', div);
        </script>
    </body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant