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

Side by Side Diff: LayoutTests/http/tests/css/resources/referrer-check.php

Issue 239353007: Set proper referrer for css resource fetching (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add test Created 6 years, 8 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 <?php
2
3 function getReferrerPath() {
4 if (!isset($_SERVER["HTTP_REFERER"]))
5 return "";
6 $url = parse_url($_SERVER["HTTP_REFERER"]);
7 return $url['path'];
8 }
9
10 function putImage() {
11 $image = "../../resources/square100.png";
12 header("Content-Type: image/png");
13 header("Content-Length: " . filesize($image));
14 ob_clean();
15 flush();
16 readfile($image);
17 }
18
19 function putFont() {
20 $font = "../../../../resources/Ahem.ttf";
21 header("Content-Type: font/truetype");
22 header("Content-Length: " . filesize($font));
23 ob_clean();
24 flush();
25 readfile($font);
26 }
27
28 $expectedReferrerPaths = array(
29 "document" => "/css/css-resources-referrer.html",
30 "sheet" => "/css/resources/css-resources-referrer.css",
31 "importedSheet" => "/css/resources/css-resources-referrer-import.css"
32 );
33
34 $from = $_GET["from"];
35 $resource = $_GET["resource"];
36 $referrerPath = getReferrerPath();
37
38 if ($referrerPath === $expectedReferrerPaths[$from]) {
39 if ($resource === "image" || $resource === "image2")
40 putImage();
41 else if ($resource === "font")
42 putFont();
43 else
44 header("HTTP/1.1 500 Internal Server Error");
45 } else {
46 header("HTTP/1.1 500 Internal Server Error");
47 }
48
49 ?>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698