Merge ~cjwatson/launchpad:remove-98437-workarounds into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 74c15f62b6b744f4728535128cb43a94905e8d58
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:remove-98437-workarounds
Merge into: launchpad:master
Diff against target: 187 lines (+22/-76)
7 files modified
lib/lp/app/stories/basics/notfound-error.txt (+15/-18)
lib/lp/bugs/browser/bugsubscription.py (+4/-7)
lib/lp/bugs/browser/bugtask.py (+2/-8)
lib/lp/services/webapp/publication.py (+0/-8)
lib/lp/services/webapp/tests/test_publication.py (+0/-8)
lib/lp/testing/browser.py (+1/-24)
lib/lp/translations/stories/importqueue/xx-translation-import-queue-entry.txt (+0/-3)
Reviewer Review Type Date Requested Status
Tom Wardill (community) Approve
Review via email: mp+374726@code.launchpad.net

Commit message

Remove workarounds for bug 98437, fixed in Zope

Description of the change

We've had sufficient versions of zope.app.testing and zope.testbrowser for a while.

To post a comment you must log in.
6a577ca... by Colin Watson

Remove unused import

Revision history for this message
Tom Wardill (twom) wrote :

Removal of workaround code, double yay!

review: Approve
74c15f6... by Colin Watson

Remove TestBlockingOffsitePosts.test_localhost_is_ok

This is no longer expected to pass, as we removed the corresponding
workaround.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/lp/app/stories/basics/notfound-error.txt b/lib/lp/app/stories/basics/notfound-error.txt
index ba3a48a..f6b0d75 100644
--- a/lib/lp/app/stories/basics/notfound-error.txt
+++ b/lib/lp/app/stories/basics/notfound-error.txt
@@ -29,22 +29,19 @@ It also contains instructions specific to broken links.
29If you go to a non-existent page directly, without sending a Referer:29If you go to a non-existent page directly, without sending a Referer:
30header, the 404 page does not try to link to the referring page.30header, the 404 page does not try to link to the referring page.
31And the advice about broken links is gone, replaced with advice about31And the advice about broken links is gone, replaced with advice about
32mistyped URLs.32things like mistyped URLs.
3333
34XXX 20080114 mpt: At the time of writing, this test passed if34 >>> page_with_no_referer = str(http(r"""
35'"HTTP_REFERER": self.host_and_port,' was commented out of35 ... GET /+fhqwhgads HTTP/1.1
36sourcecode/zope/src/zope/app/testing/functional.py. The test is36 ... """))
37disabled until bug 98437 is fixed.37 >>> print page_with_no_referer
3838 HTTP/1.1 404 Not Found
39 # >>> page_with_no_referer = str(http(r"""39 ...
40 # ... GET /+fhqwhgads HTTP/1.140 >>> main_content = find_main_content(page_with_no_referer)
41 # ... """))41 >>> for paragraph in main_content('p'):
42 # >>> print page_with_no_referer42 ... print extract_text(paragraph)
43 # HTTP/1.1 404 Not Found43 This page does not exist, or you may not have permission to see it.
44 # ...44 If you have been to this page before, it is possible it has been removed.
45 # >>> main_content = find_main_content(page_with_no_referer)45 Check that you are logged in with the correct account, or that you
46 # >>> for paragraph in main_content('p'):46 entered the address correctly, or search for it:
47 # ... print extract_text(paragraph)47 ...
48 # There’s no page with this address in Launchpad.
49 # Check that you entered the address correctly.
50 # ...
diff --git a/lib/lp/bugs/browser/bugsubscription.py b/lib/lp/bugs/browser/bugsubscription.py
index 544ae49..b8a689e 100644
--- a/lib/lp/bugs/browser/bugsubscription.py
+++ b/lib/lp/bugs/browser/bugsubscription.py
@@ -181,13 +181,10 @@ class BugSubscriptionSubscribeSelfView(LaunchpadFormView,
181 referer = self._return_url181 referer = self._return_url
182 context_url = canonical_url(self.context)182 context_url = canonical_url(self.context)
183183
184 # XXX bdmurray 2010-09-30 bug=98437: work around zope's test184 # Ignore the current request URL and the context URL as far as
185 # browser setting referer to localhost.185 # referrers are concerned so that we can handle privacy issues
186 # We also ignore the current request URL and the context URL as186 # properly.
187 # far as referrers are concerned so that we can handle privacy187 ignored_referrer_urls = (self.request.getURL(), context_url)
188 # issues properly.
189 ignored_referrer_urls = (
190 'localhost', self.request.getURL(), context_url)
191 if referer and referer not in ignored_referrer_urls:188 if referer and referer not in ignored_referrer_urls:
192 next_url = referer189 next_url = referer
193 elif self._redirecting_to_bug_list:190 elif self._redirecting_to_bug_list:
diff --git a/lib/lp/bugs/browser/bugtask.py b/lib/lp/bugs/browser/bugtask.py
index 0b9ec84..b25e213 100644
--- a/lib/lp/bugs/browser/bugtask.py
+++ b/lib/lp/bugs/browser/bugtask.py
@@ -464,10 +464,7 @@ class BugTaskView(LaunchpadView, BugViewMixin, FeedsMixin):
464 def next_url(self):464 def next_url(self):
465 """Provided so returning to the page they came from works."""465 """Provided so returning to the page they came from works."""
466 referer = self.request.getHeader('referer')466 referer = self.request.getHeader('referer')
467467 if referer:
468 # XXX bdmurray 2010-09-30 bug=98437: work around zope's test
469 # browser setting referer to localhost.
470 if referer and referer != 'localhost':
471 next_url = referer468 next_url = referer
472 else:469 else:
473 next_url = canonical_url(self.context)470 next_url = canonical_url(self.context)
@@ -477,10 +474,7 @@ class BugTaskView(LaunchpadView, BugViewMixin, FeedsMixin):
477 def cancel_url(self):474 def cancel_url(self):
478 """Provided so returning to the page they came from works."""475 """Provided so returning to the page they came from works."""
479 referer = self.request.getHeader('referer')476 referer = self.request.getHeader('referer')
480477 if referer:
481 # XXX bdmurray 2010-09-30 bug=98437: work around zope's test
482 # browser setting referer to localhost.
483 if referer and referer != 'localhost':
484 cancel_url = referer478 cancel_url = referer
485 else:479 else:
486 cancel_url = canonical_url(self.context)480 cancel_url = canonical_url(self.context)
diff --git a/lib/lp/services/webapp/publication.py b/lib/lp/services/webapp/publication.py
index ece870a..716dd2e 100644
--- a/lib/lp/services/webapp/publication.py
+++ b/lib/lp/services/webapp/publication.py
@@ -153,14 +153,6 @@ def maybe_block_offsite_form_post(request):
153 referrer = request.getHeader('referer') # Match HTTP spec misspelling.153 referrer = request.getHeader('referer') # Match HTTP spec misspelling.
154 if not referrer:154 if not referrer:
155 raise NoReferrerError('No value for REFERER header')155 raise NoReferrerError('No value for REFERER header')
156 # XXX: jamesh 2007-04-26 bug=98437:
157 # The Zope testing infrastructure sets a default (incorrect)
158 # referrer value of "localhost" or "localhost:9000" if no
159 # referrer is included in the request. We let it pass through
160 # here for the benefits of the tests. Web browsers send full
161 # URLs so this does not open us up to extra XSRF attacks.
162 if referrer in ['localhost', 'localhost:9000']:
163 return
164 # Extract the hostname from the referrer URI156 # Extract the hostname from the referrer URI
165 try:157 try:
166 hostname = URI(referrer).host158 hostname = URI(referrer).host
diff --git a/lib/lp/services/webapp/tests/test_publication.py b/lib/lp/services/webapp/tests/test_publication.py
index 76253da..335f999 100644
--- a/lib/lp/services/webapp/tests/test_publication.py
+++ b/lib/lp/services/webapp/tests/test_publication.py
@@ -203,14 +203,6 @@ class TestBlockingOffsitePosts(TestCase):
203 request = LaunchpadTestRequest(method='SOMETHING')203 request = LaunchpadTestRequest(method='SOMETHING')
204 maybe_block_offsite_form_post(request)204 maybe_block_offsite_form_post(request)
205205
206 def test_localhost_is_ok(self):
207 # we accept "localhost" and "localhost:9000" as valid referrers. See
208 # comments in the code as to why and for a related bug report.
209 request = LaunchpadTestRequest(
210 method='POST', environ=dict(PATH_INFO='/', REFERER='localhost'))
211 # this doesn't raise an exception
212 maybe_block_offsite_form_post(request)
213
214 def test_whitelisted_paths(self):206 def test_whitelisted_paths(self):
215 # There are a few whitelisted POST targets that don't require the207 # There are a few whitelisted POST targets that don't require the
216 # referrer be LP. See comments in the code as to why and for related208 # referrer be LP. See comments in the code as to why and for related
diff --git a/lib/lp/testing/browser.py b/lib/lp/testing/browser.py
index e858d95..9df40df 100644
--- a/lib/lp/testing/browser.py
+++ b/lib/lp/testing/browser.py
@@ -30,10 +30,7 @@ import urllib2
30import weakref30import weakref
3131
32import transaction32import transaction
33from zope.testbrowser.browser import (33from zope.testbrowser.browser import Browser as _Browser
34 Browser as _Browser,
35 fix_exception_name,
36 )
3734
38from lp.testing.pages import (35from lp.testing.pages import (
39 extract_text,36 extract_text,
@@ -103,26 +100,6 @@ class Browser(_Browser):
103 super(Browser, self)._changed()100 super(Browser, self)._changed()
104 transaction.commit()101 transaction.commit()
105102
106 def _clickSubmit(self, form, control, coord):
107 # XXX gary 2010-03-08 bug=98437
108 # This change is taken from
109 # https://bugs.launchpad.net/zope3/+bug/98437/comments/9 . It
110 # should be pushed upstream, per that comment.
111 labels = control.get_labels()
112 if labels:
113 label = labels[0].text
114 else:
115 label = None
116 self.mech_browser.form = form
117 self._start_timer()
118 try:
119 self.mech_browser.submit(id=control.id, name=control.name,
120 label=label, coord=coord)
121 except Exception as e:
122 fix_exception_name(e)
123 raise
124 self._stop_timer()
125
126 @property103 @property
127 def vhost(self):104 def vhost(self):
128 uri = URI(self.url)105 uri = URI(self.url)
diff --git a/lib/lp/translations/stories/importqueue/xx-translation-import-queue-entry.txt b/lib/lp/translations/stories/importqueue/xx-translation-import-queue-entry.txt
index 3d70b1d..0076838 100644
--- a/lib/lp/translations/stories/importqueue/xx-translation-import-queue-entry.txt
+++ b/lib/lp/translations/stories/importqueue/xx-translation-import-queue-entry.txt
@@ -7,9 +7,6 @@ Submission and cancellation links
7If we load an import queue entry directly from the global import queue and7If we load an import queue entry directly from the global import queue and
8approve it, we end up back on the global translations import queue.8approve it, we end up back on the global translations import queue.
99
10XXX DaniloSegan 2009-09-01: due to Zope bug #98437 we can't test that
11this works properly when no "referer" header is sent.
12
13 >>> admin_browser.open('http://translations.launchpad.test/+imports')10 >>> admin_browser.open('http://translations.launchpad.test/+imports')
14 >>> admin_browser.getLink(url='imports/1').click()11 >>> admin_browser.getLink(url='imports/1').click()
15 >>> print(admin_browser.getLink('Cancel').url)12 >>> print(admin_browser.getLink('Cancel').url)

Subscribers

People subscribed via source and target branches

to status/vote changes: