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

Fixes client DOM XSS issue #3974

Merged
merged 8 commits into from
Oct 10, 2024
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