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

Collected Pages - Download Raw HTML truncated #6

Open
Techbrunch opened this issue Jun 21, 2021 · 1 comment
Open

Collected Pages - Download Raw HTML truncated #6

Techbrunch opened this issue Jun 21, 2021 · 1 comment

Comments

@Techbrunch
Copy link

Techbrunch commented Jun 21, 2021

For some reasons the download file is truncated but we can see the full page when using View Raw HTML in new Tab.

I'll see if I can create a pull request when I have the time.

@4ag2
Copy link

4ag2 commented Sep 5, 2024

It is because of the presence of '#' character in the HTML. The '#' represents a fragment identifier in HTML.
In the file: https://github.com/mandatoryprogrammer/xsshunter-express/blob/main/front-end/src/pages/CollectedPages.vue specifically in line: 106 there is a function 'download_html'


download_html(input_html) {
            const link = document.createElement('a');
            link.href = `data:text/html,${input_html}`;
            link.download = 'xss-page-contents.html';
            link.click();
        },

When constructing a data: the URL with '#', everything after the '#' is treated as a fragment, which explains why the content gets truncated.

To solve this you can encode the HTML content properly using encodeURIComponent(), which will ensure that all special characters, including #, are treated correctly.

Solution:

download_html(input_html) {
     const encodedHtml = encodeURIComponent(input_html);
     const link = document.createElement('a');
     link.href = `data:text/html,${encodedHtml}`;
     link.download = 'xss-page-contents.html';
     link.click();
}

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

2 participants