Skip to content

Commit f7f6cf8

Browse files
committed
add csp nonce when needed
1 parent 0107d73 commit f7f6cf8

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

.github/workflows/ci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ jobs:
4747
- name: Build
4848
run: |
4949
npx parcel build --public-url /dist/
50+
./add_csp_nonce.sh
5051
cp dist/spreadsheet_component.html spreadsheet.dist.handlebars
5152
npx parcel build --public-url https://lovasoa.github.io/sqlpage-spreadsheet/${{ steps.get_version.outputs.VERSION }}/dist/
53+
./add_csp_nonce.sh
5254
cp dist/spreadsheet_component.html spreadsheet.handlebars
5355
5456
- name: Create Release ZIP

add_csp_nonce.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
sed \
4+
--in-place \
5+
--regexp-extended \
6+
--expression='s/<script (nonce="[^"]*")?/<script nonce="{{@csp_nonce}}"/g' \
7+
"dist/spreadsheet_component.html"
8+
9+
echo "CSP nonce added to spreadsheet_component.html"

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"source": "./src/spreadsheet_component.html",
66
"browserslist": "> 3%, last 2 versions, not dead",
77
"scripts": {
8-
"build": "parcel build --no-optimize --public-url /dist/",
8+
"build": "parcel build --no-optimize --public-url /dist/ && ./add_csp_nonce.sh",
9+
"build-optimized": "parcel build --public-url /dist/ && ./add_csp_nonce.sh",
910
"dev": "parcel watch --public-url /dist/ & (cd demo && ./sqlpage.bin)",
1011
"lint": "biome check",
1112
"typecheck": "tsc --noEmit",

src/spreadsheet_component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ <h5 class="modal-title">Cell Update</h5>
5454
</div>
5555
</div>
5656

57-
<script type="module" nonce="{{@csp_nonce}}" src="./spreadsheet.ts"></script>
57+
<script nonce="{{@csp_nonce}}" type="module" src="./spreadsheet.ts"></script>

0 commit comments

Comments
 (0)