Skip to content

Commit 766ad96

Browse files
committed
Fixes csp issues with the GitLens icon font
1 parent 878056a commit 766ad96

File tree

11 files changed

+55
-23
lines changed

11 files changed

+55
-23
lines changed

.fantasticonrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const config = {
77
codepoints: require('./images/icons/template/mapping.json'),
88
inputDir: './images/icons',
99
outputDir: './dist',
10+
fontsUrl: '#{root}/dist',
1011
// @ts-ignore
1112
fontTypes: ['woff2'],
1213
normalize: true,

images/icons/template/styles.hbs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
@font-face {
2-
font-family: '{{ name }}';
3-
font-display: block;
4-
src: {{{ fontSrc }}};
5-
}
1+
/*
2+
3+
Must be placed at the end of body in the HTML file of any webview that needs it (because of CSP)
4+
5+
<style nonce="#{cspNonce}">
6+
@font-face {
7+
font-family: '{{ name }}';
8+
font-display: block;
9+
src: {{{ fontSrc }}};
10+
}
11+
</style>
12+
*/
613

714
.glicon {
815
font: normal normal normal 16px/1 {{ name }};

src/webviews/apps/commitDetails/commitDetails.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ <h2>Best practice</h2>
6666
href="#"
6767
data-action="commit-actions"
6868
data-action-type="graph"
69-
aria-label="Show Commit on Commit Graph"
70-
title="Show Commit on Commit Graph"
69+
aria-label="Show in Commit Graph"
70+
title="Show in Commit Graph"
7171
><code-icon icon="graph"></code-icon
7272
></a>
7373
<a
@@ -133,7 +133,15 @@ <h2>Best practice</h2>
133133
<style nonce="#{cspNonce}">
134134
@font-face {
135135
font-family: 'codicon';
136-
src: url('#{webroot}/codicon.ttf?404cbc4fe3a64b9a93064eef76704c79') format('truetype');
136+
font-display: block;
137+
src: url('#{webroot}/codicon.ttf?0e5b0adf625a37fbcd638d31f0fe72aa') format('truetype');
138+
}
139+
</style>
140+
<style nonce="#{cspNonce}">
141+
@font-face {
142+
font-family: 'glicons';
143+
font-display: block;
144+
src: url("#{root}/dist/glicons.woff2?2e51fe40df2abdf6a27fbae6c29587b1") format("woff2");
137145
}
138146
</style>
139147
</body>

src/webviews/apps/home/home.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
<style nonce="#{cspNonce}">
2020
@font-face {
2121
font-family: 'codicon';
22-
src: url('#{webroot}/codicon.ttf?404cbc4fe3a64b9a93064eef76704c79') format('truetype');
22+
font-display: block;
23+
src: url('#{webroot}/codicon.ttf?0e5b0adf625a37fbcd638d31f0fe72aa') format('truetype');
2324
}
2425
</style>
2526
</body>

src/webviews/apps/plus/graph/graph.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@
1212
<style nonce="#{cspNonce}">
1313
@font-face {
1414
font-family: 'codicon';
15-
src: url('#{webroot}/codicon.ttf?404cbc4fe3a64b9a93064eef76704c79') format('truetype');
15+
font-display: block;
16+
src: url('#{webroot}/codicon.ttf?0e5b0adf625a37fbcd638d31f0fe72aa') format('truetype');
17+
}
18+
</style>
19+
<style nonce="#{cspNonce}">
20+
@font-face {
21+
font-family: 'glicons';
22+
font-display: block;
23+
src: url('#{root}/dist/glicons.woff2?2e51fe40df2abdf6a27fbae6c29587b1') format('woff2');
1624
}
1725
</style>
1826
</body>

src/webviews/apps/plus/timeline/timeline.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ <h1 data-bind="empty"></h1>
5151
<style nonce="#{cspNonce}">
5252
@font-face {
5353
font-family: 'codicon';
54-
src: url('#{root}/dist/webviews/codicon.ttf?669d352dfabff8f6eaa466c8ae820e43') format('truetype');
54+
font-display: block;
55+
src: url('#{webroot}/codicon.ttf?0e5b0adf625a37fbcd638d31f0fe72aa') format('truetype');
5556
}
5657
</style>
5758
</body>

src/webviews/apps/rebase/rebase.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ <h4 id="subhead"></h4>
5858
<style nonce="#{cspNonce}">
5959
@font-face {
6060
font-family: 'codicon';
61-
src: url('#{webroot}/codicon.ttf?404cbc4fe3a64b9a93064eef76704c79') format('truetype');
61+
font-display: block;
62+
src: url('#{webroot}/codicon.ttf?0e5b0adf625a37fbcd638d31f0fe72aa') format('truetype');
6263
}
6364
</style>
6465
</body>

src/webviews/apps/settings/settings.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ <h2>Jump to</h2>
327327
<style nonce="#{cspNonce}">
328328
@font-face {
329329
font-family: 'codicon';
330-
src: url('#{webroot}/codicon.ttf?404cbc4fe3a64b9a93064eef76704c79') format('truetype');
330+
font-display: block;
331+
src: url('#{webroot}/codicon.ttf?0e5b0adf625a37fbcd638d31f0fe72aa') format('truetype');
331332
}
332333
</style>
333334
</body>

src/webviews/apps/shared/glicons.scss

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
@font-face {
2-
font-family: 'glicons';
3-
font-display: block;
4-
src: url("./glicons.woff2?2e51fe40df2abdf6a27fbae6c29587b1") format("woff2");
5-
}
1+
/*
2+
3+
Must be placed at the end of body in the HTML file of any webview that needs it (because of CSP)
4+
5+
<style nonce="#{cspNonce}">
6+
@font-face {
7+
font-family: 'glicons';
8+
font-display: block;
9+
src: url("#{root}/dist/glicons.woff2?2e51fe40df2abdf6a27fbae6c29587b1") format("woff2");
10+
}
11+
</style>
12+
*/
613

714
.glicon {
815
font: normal normal normal 16px/1 glicons;

src/webviews/apps/welcome/welcome.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,8 @@ <h2>
526526
<style nonce="#{cspNonce}">
527527
@font-face {
528528
font-family: 'codicon';
529-
src: url('#{webroot}/codicon.ttf?404cbc4fe3a64b9a93064eef76704c79') format('truetype');
529+
font-display: block;
530+
src: url('#{webroot}/codicon.ttf?0e5b0adf625a37fbcd638d31f0fe72aa') format('truetype');
530531
}
531532
</style>
532533
</body>

0 commit comments

Comments
 (0)