mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 14:15:30 +00:00
Bug 362156. Support the 'feed' link relation for autodiscovery. r=gavin
This commit is contained in:
parent
7ca9838e94
commit
f9e7ca6e33
@ -5620,26 +5620,34 @@ var FeedHandler = {
|
||||
var erel = event.target.rel;
|
||||
var etype = event.target.type;
|
||||
var etitle = event.target.title;
|
||||
const alternateRelRegex = /(^|\s)alternate($|\s)/i;
|
||||
const stylesheetRelRegex = /(^|\s)stylesheet($|\s)/i;
|
||||
const rssTitleRegex = /(^|\s)rss($|\s)/i;
|
||||
|
||||
if (!alternateRelRegex.test(erel) || stylesheetRelRegex.test(erel) ||
|
||||
!etype)
|
||||
var rels = {}
|
||||
for each (var relValue in erel.split(/\s/)) {
|
||||
rels[relValue] = true;
|
||||
}
|
||||
var isFeed = rels["feed"];
|
||||
|
||||
if (!isFeed &&
|
||||
(!rels["alternate"] || rels["stylesheet"] || !etype))
|
||||
return;
|
||||
|
||||
etype = etype.replace(/^\s+/, "");
|
||||
etype = etype.replace(/\s+$/, "");
|
||||
etype = etype.replace(/\s*;.*/, "");
|
||||
etype = etype.toLowerCase();
|
||||
|
||||
if (etype == "application/rss+xml" ||
|
||||
etype == "application/atom+xml" ||
|
||||
(etype == "text/xml" ||
|
||||
etype == "application/xml" ||
|
||||
etype == "application/rdf+xml") &&
|
||||
rssTitleRegex.test(etitle))
|
||||
{
|
||||
if (!isFeed) {
|
||||
// Use type value
|
||||
etype = etype.replace(/^\s+/, "");
|
||||
etype = etype.replace(/\s+$/, "");
|
||||
etype = etype.replace(/\s*;.*/, "");
|
||||
etype = etype.toLowerCase();
|
||||
isFeed = (etype == "application/rss+xml" ||
|
||||
etype == "application/atom+xml");
|
||||
}
|
||||
|
||||
if (!isFeed) {
|
||||
// really slimy: general XML types with magic letters in the title
|
||||
isFeed = ((etype == "text/xml" || etype == "application/xml" ||
|
||||
etype == "application/rdf+xml") && rssTitleRegex.test(etitle));
|
||||
}
|
||||
|
||||
if (isFeed) {
|
||||
const targetDoc = event.target.ownerDocument;
|
||||
|
||||
// find which tab this is for, and set the attribute on the browser
|
||||
|
Loading…
Reference in New Issue
Block a user