Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
6
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
SeaMonkey 2.53 Comm
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
SeaMonkey Project
SeaMonkey 2.53 Comm
Commits
8869b45a
Commit
8869b45a
authored
Dec 29, 2019
by
Ian Neal
Committed by
Frank-Rainer Grahl
Dec 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 1576126 - Port Bug 961529 "Add Feeds module" to SeaMonkey. r=frg a=frg
parent
3b3162fb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
34 deletions
+71
-34
suite/base/content/utilityOverlay.js
suite/base/content/utilityOverlay.js
+0
-30
suite/browser/linkToolbarHandler.js
suite/browser/linkToolbarHandler.js
+4
-1
suite/browser/pageinfo/feeds.js
suite/browser/pageinfo/feeds.js
+4
-1
suite/browser/test/browser/browser_bug413915.js
suite/browser/test/browser/browser_bug413915.js
+12
-2
suite/modules/Feeds.jsm
suite/modules/Feeds.jsm
+50
-0
suite/modules/moz.build
suite/modules/moz.build
+1
-0
No files found.
suite/base/content/utilityOverlay.js
View file @
8869b45a
...
...
@@ -1317,36 +1317,6 @@ function disablePopupBlockerNotifications()
Services
.
prefs
.
setBoolPref
(
"
privacy.popups.showBrowserMessage
"
,
false
);
}
/**
* isValidFeed: checks whether the given data represents a valid feed.
*
* @param aData
* An object representing a feed with title, href and type.
* @param aPrincipal
* The principal of the document, used for security check.
* @param aIsFeed
* Whether this is already a known feed or not, if true only a security
* check will be performed.
*/
function
isValidFeed
(
aData
,
aPrincipal
,
aIsFeed
)
{
if
(
!
aData
||
!
aPrincipal
)
return
null
;
var
type
=
aData
.
type
.
toLowerCase
().
replace
(
/^
\s
+|
\s
*
(?:
;.*
)?
$/g
,
""
);
if
(
aIsFeed
||
/^application
\/(?:
atom|rss
)\+
xml$/
.
test
(
type
))
{
try
{
urlSecurityCheck
(
aData
.
href
,
aPrincipal
,
Ci
.
nsIScriptSecurityManager
.
DISALLOW_INHERIT_PRINCIPAL
);
return
type
||
"
application/rss+xml
"
;
}
catch
(
ex
)
{
}
}
return
null
;
}
// Used as an onclick handler for UI elements with link-like behavior.
// e.g. onclick="checkForMiddleClick(this, event);"
function
checkForMiddleClick
(
node
,
event
)
{
...
...
suite/browser/linkToolbarHandler.js
View file @
8869b45a
...
...
@@ -2,6 +2,9 @@
* 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/. */
XPCOMUtils
.
defineLazyModuleGetter
(
this
,
"
Feeds
"
,
"
resource:///modules/Feeds.jsm
"
);
/**
* LinkToolbarHandler is a Singleton that displays LINK elements
* and nodeLists of LINK elements in the Link Toolbar. It
...
...
@@ -82,7 +85,7 @@ function(relAttribute, element)
isFeed
=
true
;
// fall through
case
"
alternate
"
:
if
(
isValidFeed
(
element
,
element
.
nodePrincipal
,
isFeed
))
{
if
(
Feeds
.
isValidFeed
(
element
,
element
.
nodePrincipal
,
isFeed
))
{
return
"
feed
"
;
}
...
...
suite/browser/pageinfo/feeds.js
View file @
8869b45a
...
...
@@ -3,6 +3,9 @@
* 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/. */
XPCOMUtils
.
defineLazyModuleGetter
(
this
,
"
Feeds
"
,
"
resource:///modules/Feeds.jsm
"
);
function
initFeedTab
()
{
const
feedTypes
=
{
...
...
@@ -25,7 +28,7 @@ function initFeedTab()
var
isFeed
=
/
(?:
^|
\s)
feed
(?:\s
|$
)
/i
.
test
(
rel
);
if
(
isFeed
||
(
/
(?:
^|
\s)
alternate
(?:\s
|$
)
/i
.
test
(
rel
)
&&
!
/
(?:
^|
\s)
stylesheet
(?:\s
|$
)
/i
.
test
(
rel
)))
{
var
type
=
isValidFeed
(
link
,
link
.
nodePrincipal
,
isFeed
);
var
type
=
Feeds
.
isValidFeed
(
link
,
link
.
nodePrincipal
,
isFeed
);
if
(
type
)
{
if
(
type
in
feedTypes
)
type
=
feedTypes
[
type
];
...
...
suite/browser/test/browser/browser_bug413915.js
View file @
8869b45a
XPCOMUtils
.
defineLazyModuleGetter
(
this
,
"
Feeds
"
,
"
resource:///modules/Feeds.jsm
"
);
function
test
()
{
var
ioserv
=
Cc
[
"
@mozilla.org/network/io-service;1
"
]
.
getService
(
Ci
.
nsIIOService
);
...
...
@@ -7,8 +10,15 @@ function test() {
var
principal
=
secman
.
createCodebasePrincipal
(
exampleUri
,
{});
function
testIsFeed
(
aTitle
,
aHref
,
aType
,
aKnown
)
{
var
link
=
{
title
:
aTitle
,
href
:
aHref
,
type
:
aType
};
return
isValidFeed
(
link
,
principal
,
aKnown
);
var
link
=
{
title
:
aTitle
,
href
:
aHref
,
type
:
aType
,
ownerDocument
:
{
characterSet
:
"
UTF-8
"
}
};
return
Feeds
.
isValidFeed
(
link
,
principal
,
aKnown
);
}
var
href
=
"
http://example.com/feed/
"
;
...
...
suite/modules/Feeds.jsm
0 → 100644
View file @
8869b45a
/* 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";
var EXPORTED_SYMBOLS = [ "Feeds" ];
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils",
"resource://gre/modules/BrowserUtils.jsm");
var Feeds = {
/**
* isValidFeed: checks whether the given data represents a valid feed.
*
* @param aLink
* An object representing a feed with title, href and type.
* @param aPrincipal
* The principal of the document, used for security check.
* @param aIsFeed
* Whether this is already a known feed or not, if true only a security
* check will be performed.
*/
isValidFeed(aLink, aPrincipal, aIsFeed) {
if (!aLink || !aPrincipal)
return false;
var type = aLink.type.toLowerCase().replace(/^\s+|\s*(?:;.*)?$/g, "");
if (!aIsFeed) {
aIsFeed = (type == "application/rss+xml" ||
type == "application/atom+xml");
}
if (aIsFeed) {
try {
let href = BrowserUtils.makeURI(aLink.href, aLink.ownerDocument.characterSet)
BrowserUtils.urlSecurityCheck(href, aPrincipal,
Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
return type || "application/rss+xml";
} catch (ex) {
}
}
return null;
},
};
suite/modules/moz.build
View file @
8869b45a
...
...
@@ -6,6 +6,7 @@
XPCSHELL_TESTS_MANIFESTS
+=
[
'test/unit/xpcshell.ini'
]
EXTRA_JS_MODULES
+=
[
'Feeds.jsm'
,
'PermissionUI.jsm'
,
'RecentWindow.jsm'
,
'Sanitizer.jsm'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment