This repository was archived by the owner on Nov 22, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 3939 var NAME = "FontMetrics Library"
4040 var VERSION = "1-2012.0121.1300" ;
4141
42+ var entityMap = {
43+ '&' : '&' ,
44+ '<' : '<' ,
45+ '>' : '>' ,
46+ '"' : '"' ,
47+ "'" : ''' ,
48+ '/' : '/' ,
49+ '`' : '`' ,
50+ '=' : '='
51+ } ;
52+
53+ function escapeHtml ( string ) {
54+ return String ( string ) . replace ( / [ & < > " ' ` = \/ ] / g, function ( s ) {
55+ return entityMap [ s ] ;
56+ } ) ;
57+ }
58+
4259 // if there is no getComputedStyle, this library won't work.
4360 if ( ! document . defaultView . getComputedStyle ) {
4461 throw ( "ERROR: 'document.defaultView.getComputedStyle' not found. This library only works in browsers that can report computed CSS values." ) ;
99116 leadDiv . style . position = "absolute" ;
100117 leadDiv . style . opacity = 0 ;
101118 leadDiv . style . font = fontString ;
102- leadDiv . innerHTML = textstring + "<br/>" + textstring ;
119+ leadDiv . innerHTML = escapeHTML ( textstring ) + "<br/>" + escapeHTML ( textstring ) ;
103120 document . body . appendChild ( leadDiv ) ;
104121
105122 // make some initial guess at the text leading (using the standard TeX ratio)
You can’t perform that action at this time.
0 commit comments