Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/security/dangling-markup/src-attribute.html

Issue 2895953002: Update dangling markup mitigations. (Closed)
Patch Set: Test. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="/resources/testharness.js"></script>
3 <script src="/resources/testharnessreport.js"></script>
4 <script src="./resources/helper.js"></script>
5 <body>
6 <script>
7 // We're injecting markup via `srcdoc` so, confusingly, we need to
8 // entity-escape the "raw" content, and double-escape the "escaped"
9 // content.
10 var rawBrace = "&lt;";
11 var escapedBrace = "&amp;lt;";
12 var rawNewline = "&#10;";
13 var escapedNewline = "&amp;#10;";
14
15 var abeSizedPng = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEwAAABnAQMAA ACQMjadAAAAA1BMVEX///+nxBvIAAAAEUlEQVQ4y2MYBaNgFIwCegAABG0AAd5G4RkAAAAASUVORK5CY II=";
16 var abeSizedPngWithNewline = abeSizedPng.replace("i", "i\n");
17
18 var should_block = [
19 `<img id="dangling" src="http://127.0.0.1:8000/security/resources/abe.png?da ta=1${rawNewline}b">`,
20 `<img id="dangling" src="http://127.0.0.1:8000/security/resources/abe.png?im g=2${rawNewline}b${rawBrace}c">`,
21 `
22 <img id="dangling" src="http://127.0.0.1:8000/security/resources/abe.png?i mg=3
23 b${rawBrace}c
24 ">
25 `,
26 `<img id="dangling" src="${abeSizedPngWithNewline}">`,
27 ];
28
29 should_block.forEach(markup => {
30 async_test(t => {
31 var i = createFrame(`${markup}`);
32 assert_img_not_loaded(t, i);
33 }, markup.replace(/[\n\r]/g, ''));
34 });
35
36 var should_load = [
37 // Brace alone doesn't block:
38 `<img id="dangling" src="http://127.0.0.1:8000/security/resources/abe.png?4& img=${rawBrace}b">`,
39
40 // Entity-escaped characters don't trigger blocking:
41 `<img id="dangling" src="http://127.0.0.1:8000/security/resources/abe.png?5& data=${escapedNewline}b">`,
42 `<img id="dangling" src="http://127.0.0.1:8000/security/resources/abe.png?6& img=${escapedBrace}b">`,
43 `<img id="dangling" src="http://127.0.0.1:8000/security/resources/abe.png?7& img=${escapedNewline}b${escapedBrace}c">`,
44
45 // Leading and trailing whitespace is stripped:
46 `
47 <img id="dangling" src="
48 http://127.0.0.1:8000/security/resources/abe.png?8
49 ">
50 <input type=hidden name=csrf value=sekrit>
51 `,
52 `
53 <img id="dangling" src="
54 http://127.0.0.1:8000/security/resources/abe.png?9&img=${escapedBrace}
55 ">
56 <input type=hidden name=csrf value=sekrit>
57 `,
58 `
59 <img id="dangling" src="
60 http://127.0.0.1:8000/security/resources/abe.png?10&img=${escapedNewline}
61 ">
62 <input type=hidden name=csrf value=sekrit>
63 `,
64 ];
65
66 should_load.forEach(markup => {
67 async_test(t => {
68 var i = createFrame(`${markup} <element attr="" another=''>`);
69 assert_img_loaded(t, i);
70 }, markup.replace(/[\n\r]/g, ''));
71 });
72 </script>
73
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698