Skip to content

Commit

Permalink
Fixes client DOM XSS issue (#3974)
Browse files Browse the repository at this point in the history
  • Loading branch information
walmazacn authored Oct 10, 2024
1 parent 5584969 commit aad422e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions website/docs/src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@
<div style="display: contents">%sveltekit.body%</div>

<script type="text/javascript">
const sanitizeString = function(input) {
return input ? input.replace(/[^a-z0-9-/]/gim, '').toLowerCase() : '';
};
const locationPath = sanitizeString(location.pathname);
const pathNameIndex = locationPath.lastIndexOf('/') + 1;

// Import LuigiClient into each microfrontend
let script = document.createElement('script');
script.type = 'text/javascript';
script.src = '/luigi-client/luigi-client.js';
document.getElementsByTagName('body')[0].appendChild(script);
document.body.classList.add(
'page-' + location.pathname.substring(location.pathname.lastIndexOf('/') + 1)
);
document.body.classList.add('page-' + locationPath.substring(pathNameIndex));

// Modify WC API docu labels manually for added clarity through title attribute
document.addEventListener('DOMContentLoaded', function() {
Expand Down

0 comments on commit aad422e

Please sign in to comment.