Skip to content

Commit ef69c0a

Browse files
committed
Bug 1868677 - Re-enable HTML fragment sanitization on about:newtab and about:home r=Gijs
In bug 1600941, HTML fragment sanitization was enabled in about: pages. Sadly, it had to be disabled on about:newtab and about:home in bug 1609635 because remote snippets could contain arbitrarily placed anchor tags in their content. Now that remote snippets are gone (bug 1715158), we can re-enable HTML fragment sanitization on about:newtab and about:home! Differential Revision: https://phabricator.services.mozilla.com/D195736
1 parent 5270f0b commit ef69c0a

File tree

4 files changed

+3
-30
lines changed

4 files changed

+3
-30
lines changed

browser/components/about/AboutRedirector.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ static const uint32_t ACTIVITY_STREAM_FLAGS =
2424
nsIAboutModule::ALLOW_SCRIPT | nsIAboutModule::ENABLE_INDEXED_DB |
2525
nsIAboutModule::URI_MUST_LOAD_IN_CHILD |
2626
nsIAboutModule::URI_CAN_LOAD_IN_PRIVILEGEDABOUT_PROCESS |
27-
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
28-
nsIAboutModule::ALLOW_UNSANITIZED_CONTENT;
27+
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT;
2928

3029
struct RedirEntry {
3130
const char* id;

dom/base/nsContentUtils.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5435,17 +5435,6 @@ uint32_t computeSanitizationFlags(nsIPrincipal* aPrincipal, int32_t aFlags) {
54355435
return sanitizationFlags;
54365436
}
54375437

5438-
/* static */
5439-
bool AllowsUnsanitizedContentForAboutNewTab(nsIPrincipal* aPrincipal) {
5440-
if (StaticPrefs::dom_about_newtab_sanitization_enabled() ||
5441-
!aPrincipal->SchemeIs("about")) {
5442-
return false;
5443-
}
5444-
uint32_t aboutModuleFlags = 0;
5445-
aPrincipal->GetAboutModuleFlags(&aboutModuleFlags);
5446-
return aboutModuleFlags & nsIAboutModule::ALLOW_UNSANITIZED_CONTENT;
5447-
}
5448-
54495438
/* static */
54505439
void nsContentUtils::SetHTMLUnsafe(FragmentOrElement* aTarget,
54515440
Element* aContext,
@@ -5514,8 +5503,7 @@ nsresult nsContentUtils::ParseFragmentHTML(
55145503
// an about: scheme principal.
55155504
bool shouldSanitize = nodePrincipal->IsSystemPrincipal() ||
55165505
nodePrincipal->SchemeIs("about") || aFlags >= 0;
5517-
if (shouldSanitize &&
5518-
!AllowsUnsanitizedContentForAboutNewTab(nodePrincipal)) {
5506+
if (shouldSanitize) {
55195507
if (!doc->IsLoadedAsData()) {
55205508
doc = nsContentUtils::CreateInertHTMLDocument(doc);
55215509
if (!doc) {

modules/libpref/init/StaticPrefList.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4730,14 +4730,6 @@
47304730
value: true
47314731
mirror: always
47324732

4733-
# about:home and about:newtab include remote snippets that contain arbitrarily
4734-
# placed anchor tags in their content; we want sanitization to be turned off
4735-
# in order to render them correctly
4736-
- name: dom.about_newtab_sanitization.enabled
4737-
type: bool
4738-
value: false
4739-
mirror: always
4740-
47414733
# Hide the confirm dialog when a POST request is reloaded.
47424734
- name: dom.confirm_repost.testing.always_accept
47434735
type: bool

netwerk/protocol/about/nsIAboutModule.idl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,10 @@ interface nsIAboutModule : nsISupports
8686
*/
8787
const unsigned long URI_MUST_LOAD_IN_EXTENSION_PROCESS = (1 << 9);
8888

89-
/**
90-
* A flag that indicates that this about: URI needs to allow unsanitized content.
91-
* Only to be used by about:home and about:newtab.
92-
*/
93-
const unsigned long ALLOW_UNSANITIZED_CONTENT = (1 << 10);
94-
9589
/**
9690
* A flag that indicates that this about: URI is a secure chrome UI
9791
*/
98-
const unsigned long IS_SECURE_CHROME_UI = (1 << 11);
92+
const unsigned long IS_SECURE_CHROME_UI = (1 << 10);
9993

10094
/**
10195
* A method to get the flags that apply to a given about: URI. The URI

0 commit comments

Comments
 (0)