actions / github-script

Write workflows scripting the GitHub API in JavaScript
MIT License
4.24k stars 424 forks source link

</script> Malformed Script Tag After B2C Page Layout Version Upgrade Causes Loading Issues #493

Open vikramAkram opened 1 month ago

vikramAkram commented 1 month ago

Describe the bug

After a B2C page layout version upgrade, the script tag for unified.min.js is not properly formatted when the page loads. Instead of closing correctly, the script tag appears as follows:

https://sampledomain/static/content/js/stage-2/unified.min.js?v=1728718798338></script>

This results in a malformed tag with an extra , causing unexpected behavior.

To Reproduce

Steps to reproduce the behavior:

Run the commands: npm run build followed by npm run server to start the application. Once the application is up and running, navigate to any page where the unified.min.js script should load. Open the browser developer tools (right-click on the page and select "Inspect"). In the "Network" tab, check the script loading section, and we will observe a malformed script tag, as shown in the screenshots.

Instead of loading properly, the script contains an extra closing tag (</script>), resulting in the following:

Expected behavior

The script tag should load and close correctly without extra tags. Expected output: https://sampledomain/static/content/js/stage-2/unified.min.js?v=1728718798338>

Screenshots

1) After B2C Page Layout Version Upgrade:

image

2) Working Screenshot (Older Version):

image

Desktop (please complete the following information):

Additional context

We've tried the following approaches to resolve the issue, but the problem persists:

existing ::

1. Webpack Configuration (HtmlWebpackPlugin): new HtmlWebpackPlugin({ filename: '../../../stage-2/unified.html', template: path.resolve(__dirname, 'src/stage-2/unified.html'), chunks: ['stage-2/unified.min'], publicPath: '/static/content/js/', inject: 'body' }),

2) Content-Security-Policy (CSP) Headers

res.setHeader('Content-Security-Policy', "default-src 'none'; script-src 'self' 'unsafe-inline'; connect-src 'self'; font-src 'self'; img-src 'self'; style-src 'self';base-uri 'self';form-action 'self'");

3. Unified.html: Moved the script tags to the section as recommended here.

https://learn.microsoft.com/en-us/azure/active-directory-b2c/javascript-and-page-layout?pivots=b2c-user-flow

image

Existing Unified.html code ::

Updated Webpack Configuration (HtmlWebpackPlugin):

new HtmlWebpackPlugin({ filename: '../../../stage-2/unified.html', template: path.resolve(__dirname, 'src/stage-2/unified.html'), chunks: ['stage-2/unified.min'], publicPath: '/static/content/js/', inject: 'body', xhtml: false, // Ensures self-closing tags like Githubissues.

  • Githubissues is a development platform for aggregating issues.