Skip to content

Commit ef3492f

Browse files
committed
remove extra nesting in new test block
1 parent 3a1a62a commit ef3492f

File tree

1 file changed

+78
-80
lines changed

1 file changed

+78
-80
lines changed

test/jasmine/tests/svg_text_utils_test.js

Lines changed: 78 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -516,111 +516,109 @@ describe('svg+text utils', function() {
516516
describe('sanitizeHTML', function() {
517517
'use strict';
518518

519-
describe('convertToTspans', function() {
520-
var stringFromCodePoint;
519+
var stringFromCodePoint;
521520

522-
beforeAll(function() {
523-
stringFromCodePoint = String.fromCodePoint;
524-
});
521+
beforeAll(function() {
522+
stringFromCodePoint = String.fromCodePoint;
523+
});
525524

526-
afterEach(function() {
527-
String.fromCodePoint = stringFromCodePoint;
528-
});
525+
afterEach(function() {
526+
String.fromCodePoint = stringFromCodePoint;
527+
});
529528

530-
function mockHTML(txt) {
531-
return util.sanitizeHTML(txt);
532-
}
529+
function mockHTML(txt) {
530+
return util.sanitizeHTML(txt);
531+
}
533532

534-
afterEach(function() {
535-
d3.selectAll('.text-tester').remove();
536-
});
533+
afterEach(function() {
534+
d3.selectAll('.text-tester').remove();
535+
});
537536

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+
);
542541

543-
expect(innerHTML).toEqual('<a>XSS</a>');
544-
});
542+
expect(innerHTML).toEqual('<a>XSS</a>');
543+
});
545544

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+
);
550549

551-
expect(innerHTML).toEqual('<a>XSS</a>');
552-
});
550+
expect(innerHTML).toEqual('<a>XSS</a>');
551+
});
553552

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+
);
558557

559-
expect(innerHTML).toEqual('<a href="/mylink">mylink</a>');
560-
});
558+
expect(innerHTML).toEqual('<a href="/mylink">mylink</a>');
559+
});
561560

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+
);
566565

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+
});
569568

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+
);
574573

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+
});
577576

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+
);
582581

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+
});
585584

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+
];
592591

593-
textCases.forEach(function(textCase) {
594-
var innerHTML = mockHTML(textCase);
592+
textCases.forEach(function(textCase) {
593+
var innerHTML = mockHTML(textCase);
595594

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>');
598596
});
597+
});
599598

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+
];
610609

611-
textCases.forEach(function(textCase) {
612-
var innerHTML = mockHTML(textCase);
610+
textCases.forEach(function(textCase) {
611+
var innerHTML = mockHTML(textCase);
613612

614-
expect(innerHTML).toEqual('<a style="y" href="x">z</a>');
615-
});
613+
expect(innerHTML).toEqual('<a style="y" href="x">z</a>');
616614
});
615+
});
617616

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+
);
622621

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>');
625623
});
626624
});

0 commit comments

Comments
 (0)