Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/netwerk/test/unit/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  test_bug464591.js   Sprache: JAVA

 
// 1.percent-encoded IDN that contains blacklisted character should be converted
//   to punycode, not UTF-8 string
// 2.only hostname-valid percent encoded ASCII characters should be decoded
// 3.IDN convertion must not bypassed by %00

"use strict";

let reference = [
  [
    "www.example.com%e2%88%95www.mozill%d0%b0.com%e2%81%84www.mozilla.org",
    "www.example.xn--comwww-re3c.xn--mozill-8nf.xn--comwww-rq0c.mozilla.org",
  ],
];

let badURIs = [
  ["www.mozill%61%2f.org"], // a slash is not valid in the hostname
  ["www.e%00xample.com%e2%88%95www.mozill%d0%b0.com%e2%81%84www.mozill%61.org"],
];

function stringToURL(str) {
  return Cc["@mozilla.org/network/standard-url-mutator;1"]
    .createInstance(Ci.nsIStandardURLMutator)
    .init(Ci.nsIStandardURL.URLTYPE_AUTHORITY, 80, str, "UTF-8"null)
    .finalize()
    .QueryInterface(Ci.nsIURL);
}

function run_test() {
  for (let i = 0; i < reference.length; ++i) {
    try {
      let result = stringToURL("http://" + reference[i][0]).host;
      equal(result, reference[i][1]);
    } catch (e) {
      ok(false"Error testing " + reference[i][0]);
    }
  }

  for (let i = 0; i < badURIs.length; ++i) {
    Assert.throws(
      () => {
        stringToURL("http://" + badURIs[i][0]).host;
      },
      /NS_ERROR_MALFORMED_URI/,
      "bad escaped character"
    );
  }
}

Messung V0.5
C=93 H=99 G=95

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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.