Files
freeCodeCamp/curriculum/challenges/chinese-traditional/09-information-security/information-security-with-helmetjs/prevent-ie-from-opening-untrusted-html-with-helmet.ienoopen.md

1.5 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
587d8248367417b2b2512c3b 使用 helment.ieNoOpen() 防止 IE 打開不受信任的 HTML 2 301584 prevent-ie-from-opening-untrusted-html-with-helmet-ienoopen

--description--

請注意,本項目在這個 Repl.it 項目的基礎上進行開發。 你也可以從GitHub上克隆。

有些網站會下載不安全的 HTML 文件。 某些版本的 IE 默認情況下還會在你網站的作用域下打開這些 HTML 文件。 換句話說,這些不安全的 HTML 頁面可以在你的網站做惡意行爲。 我們可以通過中間件來設置 header 中的 X-Download-Options 字段,讓它的值爲 noopen。 這樣就可以防止 IE 在不信任的網站下執行下載的文件。

--instructions--

應正確加載 helmet.ieNoOpen() 中間件

--hints--

helmet.ieNoOpen() 中間件應正確安裝。

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/app-info').then(
    (data) => {
      assert.include(data.appStack, 'ienoopen');
      assert.equal(data.headers['x-download-options'], 'noopen');
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

--solutions--

/**
  Backend challenges don't need solutions, 
  because they would need to be tested against a full working project. 
  Please check our contributing guidelines to learn more.
*/