File tree 2 files changed +23
-3
lines changed
2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { isMobile } from '../util/env'
2
+ import { escapeString } from '../util/core'
2
3
/**
3
4
* Render github corner
4
5
* @param {Object } data
@@ -30,6 +31,9 @@ export function corner(data, cornerExternalLinkTarge) {
30
31
* Render main content
31
32
*/
32
33
export function main ( config ) {
34
+
35
+ const name = config . name ? escapeString ( config . name ) :''
36
+
33
37
const aside =
34
38
'<button class="sidebar-toggle" aria-label="Menu">' +
35
39
'<div class="sidebar-toggle-button">' +
@@ -39,9 +43,9 @@ export function main(config) {
39
43
'<aside class="sidebar">' +
40
44
( config . name ?
41
45
`<h1 class="app-name"><a class="app-name-link" data-nosearch>${
42
- config . logo ?
43
- `<img alt=${ config . name } src=${ config . logo } >` :
44
- config . name
46
+ config . logo ?
47
+ `<img alt=" ${ name } " src=${ config . logo } >` :
48
+ name
45
49
} </a></h1>` :
46
50
'' ) +
47
51
'<div class="sidebar-nav"><!--sidebar--></div>' +
Original file line number Diff line number Diff line change @@ -56,3 +56,19 @@ export function noop() {}
56
56
export function isFn ( obj ) {
57
57
return typeof obj === 'function'
58
58
}
59
+
60
+ /**
61
+ * escape String
62
+ */
63
+ export function escapeString ( string ) {
64
+ const entityMap = {
65
+ '&' : '&' ,
66
+ '<' : '<' ,
67
+ '>' : '>' ,
68
+ '"' : '"' ,
69
+ '\'' : ''' ,
70
+ '/' : '/'
71
+ }
72
+
73
+ return String ( string ) . replace ( / [ & < > " ' / ] / g, s => entityMap [ s ] )
74
+ }
You can’t perform that action at this time.
0 commit comments