From 1240f5d9b8a2e8e9fd1640fbf09eecad84e7c9e7 Mon Sep 17 00:00:00 2001 From: "philringnalda%gmail.com" Date: Sat, 29 Dec 2007 03:30:54 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20408328=20=C3=A2=C2=80=C2=93=20Replace=20F?= =?UTF-8?q?eedWriter.js's=20CheckLoadURIStr=20with=20CheckLoadURIStrWithPr?= =?UTF-8?q?incipal,=20r=3Dsayrer,=20sr=3Dbz,=20a=3Dsayrer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://10.0.0.236/trunk@242171 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/browser/components/feeds/Makefile.in | 4 ++ .../components/feeds/src/FeedWriter.js | 10 ++- .../browser/components/feeds/test/Makefile.in | 51 +++++++++++++++ .../components/feeds/test/bug408328-data.xml | 63 +++++++++++++++++++ .../components/feeds/test/test_bug408328.html | 39 ++++++++++++ 5 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 mozilla/browser/components/feeds/test/Makefile.in create mode 100644 mozilla/browser/components/feeds/test/bug408328-data.xml create mode 100644 mozilla/browser/components/feeds/test/test_bug408328.html diff --git a/mozilla/browser/components/feeds/Makefile.in b/mozilla/browser/components/feeds/Makefile.in index 75057f2de43..f1c4c9825fc 100644 --- a/mozilla/browser/components/feeds/Makefile.in +++ b/mozilla/browser/components/feeds/Makefile.in @@ -43,4 +43,8 @@ include $(DEPTH)/config/autoconf.mk DIRS = public src +ifdef MOZ_MOCHITEST +DIRS += test +endif + include $(topsrcdir)/config/rules.mk diff --git a/mozilla/browser/components/feeds/src/FeedWriter.js b/mozilla/browser/components/feeds/src/FeedWriter.js index b12db5b2ba3..2924ee09300 100755 --- a/mozilla/browser/components/feeds/src/FeedWriter.js +++ b/mozilla/browser/components/feeds/src/FeedWriter.js @@ -130,8 +130,9 @@ FeedWriter.prototype = { getService(Ci.nsIScriptSecurityManager); const flags = Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL; try { - secman.checkLoadURIStr(this._window.location.href, uri, flags); - // checkLoadURIStr will throw if the link URI should not be loaded per + secman.checkLoadURIStrWithPrincipal(this._feedPrincipal, uri, flags); + // checkLoadURIStrWithPrincipal will throw if the link URI should not be + // loaded, either because our feedURI isn't allowed to load it or per // the rules specified in |flags|, so we'll never "linkify" the link... element.setAttribute(attribute, uri); } @@ -776,6 +777,7 @@ FeedWriter.prototype = { _window: null, _document: null, _feedURI: null, + _feedPrincipal: null, // nsIFeedWriter init: function FW_init(aWindow) { @@ -790,6 +792,10 @@ FeedWriter.prototype = { this._window = window; this._document = window.document; + var secman = Cc["@mozilla.org/scriptsecuritymanager;1"]. + getService(Ci.nsIScriptSecurityManager); + this._feedPrincipal = secman.getCodebasePrincipal(this._feedURI); + LOG("Subscribe Preview: feed uri = " + this._window.location.href); // Set up the subscription UI diff --git a/mozilla/browser/components/feeds/test/Makefile.in b/mozilla/browser/components/feeds/test/Makefile.in new file mode 100644 index 00000000000..ab6965a1538 --- /dev/null +++ b/mozilla/browser/components/feeds/test/Makefile.in @@ -0,0 +1,51 @@ +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Phil Ringnalda. +# Portions created by the Initial Developer are Copyright (C) 2007 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ +relativesrcdir = browser/components/feeds/test + +include $(DEPTH)/config/autoconf.mk +include $(topsrcdir)/config/rules.mk + +_TEST_FILES = test_bug408328.html \ + bug408328-data.xml \ + $(NULL) + +libs:: $(_TEST_FILES) + $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir) diff --git a/mozilla/browser/components/feeds/test/bug408328-data.xml b/mozilla/browser/components/feeds/test/bug408328-data.xml new file mode 100644 index 00000000000..e9385e5ab1e --- /dev/null +++ b/mozilla/browser/components/feeds/test/bug408328-data.xml @@ -0,0 +1,63 @@ + + + + Example Feed + + 2003-12-13T18:30:02Z + + + John Doe + + urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6 + + + + Good item + + urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a + 2003-12-13T18:30:02Z + + Some text. + + + + + data: link + + urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6b + 2003-12-13T18:30:03Z + + Some text. + + + + + javascript: link + + urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6c + 2003-12-13T18:30:04Z + + Some text. + + + + + file: link + + urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6d + 2003-12-13T18:30:05Z + + Some text. + + + + + chrome: link + + urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6e + 2003-12-13T18:30:06Z + + Some text. + + + diff --git a/mozilla/browser/components/feeds/test/test_bug408328.html b/mozilla/browser/components/feeds/test/test_bug408328.html new file mode 100644 index 00000000000..9636176e2ad --- /dev/null +++ b/mozilla/browser/components/feeds/test/test_bug408328.html @@ -0,0 +1,39 @@ + + + + + Test feed preview safe-linkification + + + + + +Mozilla Bug 408328 +

+ +
+
+
+ + +