@@ -516,111 +516,109 @@ describe('svg+text utils', function() {
516
516
describe ( 'sanitizeHTML' , function ( ) {
517
517
'use strict' ;
518
518
519
- describe ( 'convertToTspans' , function ( ) {
520
- var stringFromCodePoint ;
519
+ var stringFromCodePoint ;
521
520
522
- beforeAll ( function ( ) {
523
- stringFromCodePoint = String . fromCodePoint ;
524
- } ) ;
521
+ beforeAll ( function ( ) {
522
+ stringFromCodePoint = String . fromCodePoint ;
523
+ } ) ;
525
524
526
- afterEach ( function ( ) {
527
- String . fromCodePoint = stringFromCodePoint ;
528
- } ) ;
525
+ afterEach ( function ( ) {
526
+ String . fromCodePoint = stringFromCodePoint ;
527
+ } ) ;
529
528
530
- function mockHTML ( txt ) {
531
- return util . sanitizeHTML ( txt ) ;
532
- }
529
+ function mockHTML ( txt ) {
530
+ return util . sanitizeHTML ( txt ) ;
531
+ }
533
532
534
- afterEach ( function ( ) {
535
- d3 . selectAll ( '.text-tester' ) . remove ( ) ;
536
- } ) ;
533
+ afterEach ( function ( ) {
534
+ d3 . selectAll ( '.text-tester' ) . remove ( ) ;
535
+ } ) ;
537
536
538
- it ( 'checks for XSS attack in href' , function ( ) {
539
- var innerHTML = mockHTML (
540
- '<a href="javascript:alert(\'attack\')">XSS</a>'
541
- ) ;
537
+ it ( 'checks for XSS attack in href' , function ( ) {
538
+ var innerHTML = mockHTML (
539
+ '<a href="javascript:alert(\'attack\')">XSS</a>'
540
+ ) ;
542
541
543
- expect ( innerHTML ) . toEqual ( '<a>XSS</a>' ) ;
544
- } ) ;
542
+ expect ( innerHTML ) . toEqual ( '<a>XSS</a>' ) ;
543
+ } ) ;
545
544
546
- it ( 'checks for XSS attack in href (with plenty of white spaces)' , function ( ) {
547
- var innerHTML = mockHTML (
548
- '<a href = " javascript:alert(\'attack\')">XSS</a>'
549
- ) ;
545
+ it ( 'checks for XSS attack in href (with plenty of white spaces)' , function ( ) {
546
+ var innerHTML = mockHTML (
547
+ '<a href = " javascript:alert(\'attack\')">XSS</a>'
548
+ ) ;
550
549
551
- expect ( innerHTML ) . toEqual ( '<a>XSS</a>' ) ;
552
- } ) ;
550
+ expect ( innerHTML ) . toEqual ( '<a>XSS</a>' ) ;
551
+ } ) ;
553
552
554
- it ( 'whitelists relative hrefs (interpreted as http)' , function ( ) {
555
- var innerHTML = mockHTML (
556
- '<a href="/mylink">mylink</a>'
557
- ) ;
553
+ it ( 'whitelists relative hrefs (interpreted as http)' , function ( ) {
554
+ var innerHTML = mockHTML (
555
+ '<a href="/mylink">mylink</a>'
556
+ ) ;
558
557
559
- expect ( innerHTML ) . toEqual ( '<a href="/mylink">mylink</a>' ) ;
560
- } ) ;
558
+ expect ( innerHTML ) . toEqual ( '<a href="/mylink">mylink</a>' ) ;
559
+ } ) ;
561
560
562
- it ( 'whitelists http hrefs' , function ( ) {
563
- var innerHTML = mockHTML (
564
- '<a href="http://bl.ocks.org/">bl.ocks.org</a>'
565
- ) ;
561
+ it ( 'whitelists http hrefs' , function ( ) {
562
+ var innerHTML = mockHTML (
563
+ '<a href="http://bl.ocks.org/">bl.ocks.org</a>'
564
+ ) ;
566
565
567
- expect ( innerHTML ) . toEqual ( '<a href="http://bl.ocks.org/">bl.ocks.org</a>' ) ;
568
- } ) ;
566
+ expect ( innerHTML ) . toEqual ( '<a href="http://bl.ocks.org/">bl.ocks.org</a>' ) ;
567
+ } ) ;
569
568
570
- it ( 'whitelists https hrefs' , function ( ) {
571
- var innerHTML = mockHTML (
572
- '<a href="https://chart-studio.plotly.com">plotly</a>'
573
- ) ;
569
+ it ( 'whitelists https hrefs' , function ( ) {
570
+ var innerHTML = mockHTML (
571
+ '<a href="https://chart-studio.plotly.com">plotly</a>'
572
+ ) ;
574
573
575
- expect ( innerHTML ) . toEqual ( '<a href="https://chart-studio.plotly.com">plotly</a>' ) ;
576
- } ) ;
574
+ expect ( innerHTML ) . toEqual ( '<a href="https://chart-studio.plotly.com">plotly</a>' ) ;
575
+ } ) ;
577
576
578
- it ( 'whitelists mailto hrefs' , function ( ) {
579
- var innerHTML = mockHTML (
580
- '<a href="mailto:support@plotly.com">support</a>'
581
- ) ;
577
+ it ( 'whitelists mailto hrefs' , function ( ) {
578
+ var innerHTML = mockHTML (
579
+ '<a href="mailto:support@plotly.com">support</a>'
580
+ ) ;
582
581
583
- expect ( innerHTML ) . toEqual ( '<a href="mailto:support@plotly.com">support</a>' ) ;
584
- } ) ;
582
+ expect ( innerHTML ) . toEqual ( '<a href="mailto:support@plotly.com">support</a>' ) ;
583
+ } ) ;
585
584
586
- it ( 'drops XSS attacks in href' , function ( ) {
587
- // "XSS" gets interpreted as a relative link (http)
588
- var textCases = [
589
- '<a href="XSS\" onmouseover="alert(1)\" style="font-size:300px">Subtitle</a>' ,
590
- '<a href="XSS" onmouseover="alert(1)" style="font-size:300px">Subtitle</a>'
591
- ] ;
585
+ it ( 'drops XSS attacks in href' , function ( ) {
586
+ // "XSS" gets interpreted as a relative link (http)
587
+ var textCases = [
588
+ '<a href="XSS\" onmouseover="alert(1)\" style="font-size:300px">Subtitle</a>' ,
589
+ '<a href="XSS" onmouseover="alert(1)" style="font-size:300px">Subtitle</a>'
590
+ ] ;
592
591
593
- textCases . forEach ( function ( textCase ) {
594
- var innerHTML = mockHTML ( textCase ) ;
592
+ textCases . forEach ( function ( textCase ) {
593
+ var innerHTML = mockHTML ( textCase ) ;
595
594
596
- expect ( innerHTML ) . toEqual ( '<a style="font-size:300px" href="XSS">Subtitle</a>' ) ;
597
- } ) ;
595
+ expect ( innerHTML ) . toEqual ( '<a style="font-size:300px" href="XSS">Subtitle</a>' ) ;
598
596
} ) ;
597
+ } ) ;
599
598
600
- it ( 'accepts href and style in <a> in any order and tosses other stuff' , function ( ) {
601
- var textCases = [
602
- '<a href="x" style="y">z</a>' ,
603
- '<a href=\'x\' style="y">z</a>' ,
604
- '<A HREF="x"StYlE=\'y\'>z</a>' ,
605
- '<a style=\'y\'href=\'x\'>z</A>' ,
606
- '<a \t\r\n href="x" \n\r\t style="y" \n \t \r>z</a>' ,
607
- '<a magic="true" href="x" weather="cloudy" style="y" speed="42">z</a>' ,
608
- '<a href="x" style="y">z</a href="nope" style="for real?">' ,
609
- ] ;
599
+ it ( 'accepts href and style in <a> in any order and tosses other stuff' , function ( ) {
600
+ var textCases = [
601
+ '<a href="x" style="y">z</a>' ,
602
+ '<a href=\'x\' style="y">z</a>' ,
603
+ '<A HREF="x"StYlE=\'y\'>z</a>' ,
604
+ '<a style=\'y\'href=\'x\'>z</A>' ,
605
+ '<a \t\r\n href="x" \n\r\t style="y" \n \t \r>z</a>' ,
606
+ '<a magic="true" href="x" weather="cloudy" style="y" speed="42">z</a>' ,
607
+ '<a href="x" style="y">z</a href="nope" style="for real?">' ,
608
+ ] ;
610
609
611
- textCases . forEach ( function ( textCase ) {
612
- var innerHTML = mockHTML ( textCase ) ;
610
+ textCases . forEach ( function ( textCase ) {
611
+ var innerHTML = mockHTML ( textCase ) ;
613
612
614
- expect ( innerHTML ) . toEqual ( '<a style="y" href="x">z</a>' ) ;
615
- } ) ;
613
+ expect ( innerHTML ) . toEqual ( '<a style="y" href="x">z</a>' ) ;
616
614
} ) ;
615
+ } ) ;
617
616
618
- it ( 'allows encoded URIs in href' , function ( ) {
619
- var innerHTML = mockHTML (
620
- '<a href="https://example.com/?q=date%20%3E=%202018-01-01">click</a>'
621
- ) ;
617
+ it ( 'allows encoded URIs in href' , function ( ) {
618
+ var innerHTML = mockHTML (
619
+ '<a href="https://example.com/?q=date%20%3E=%202018-01-01">click</a>'
620
+ ) ;
622
621
623
- expect ( innerHTML ) . toEqual ( '<a href="https://example.com/?q=date%20%3E=%202018-01-01">click</a>' ) ;
624
- } ) ;
622
+ expect ( innerHTML ) . toEqual ( '<a href="https://example.com/?q=date%20%3E=%202018-01-01">click</a>' ) ;
625
623
} ) ;
626
624
} ) ;
0 commit comments