/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- * vim: sw=2 ts=2 sts=2 * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// STS parser tests
let sss = Cc["@mozilla.org/ssservice;1"].getService(Ci.nsISiteSecurityService);
function test_valid_header(header, expectedMaxAge, expectedIncludeSubdomains) {
let dummyUri = Services.io.newURI("https://foo.com/bar.html");
let maxAge = {};
let includeSubdomains = {};
// these are weird tests, but are testing that some extended syntax is // still allowed (but it is ignored)
test_valid_header("max-age=100 ; includesubdomainsSomeStuff", 100, false);
test_valid_header( "\r\n\t\t \tcompletelyUnrelated = foobar; max-age= 34520103" + "\t \t; alsoUnrelated;asIsThis;\tincludeSubdomains\t\t \t",
34520103, true
);
test_valid_header('max-age=100; unrelated="quoted \\"thingy\\""', 100, false);
// Test a max-age greater than 100 years. It will be capped at 100 years.
test_valid_header("max-age=4294967296", 60 * 60 * 24 * 365 * 100, false);
// invalid headers
test_invalid_header("foobar");
test_invalid_header("maxage=100");
test_invalid_header("maxa-ge=100");
test_invalid_header("max-ag=100");
test_invalid_header("includesubdomains");
test_invalid_header("includesubdomains=");
test_invalid_header("max-age=100; includesubdomains=");
test_invalid_header(";");
test_invalid_header('max-age="100'); // The max-age directive here doesn't conform to the spec, so it MUST // be ignored. Consequently, the REQUIRED max-age directive is not // present in this header, and so it is invalid.
test_invalid_header("max-age=100, max-age=200; includeSubdomains");
test_invalid_header("max-age=100 includesubdomains");
test_invalid_header("max-age=100 bar foo");
test_invalid_header("max-age=100randomstuffhere"); // All directives MUST appear only once in an STS header field.
test_invalid_header("max-age=100; max-age=200");
test_invalid_header("includeSubdomains; max-age=200; includeSubdomains");
test_invalid_header("max-age=200; includeSubdomains; includeSubdomains"); // The includeSubdomains directive is valueless.
test_invalid_header("max-age=100; includeSubdomains=unexpected"); // LWS must have at least one space or horizontal tab
test_invalid_header("\r\nmax-age=200");
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.