Merge lp:~danilo/launchpad/revert-xss-workaround into lp:launchpad

Proposed by Данило Шеган
Status: Merged
Approved by: Данило Шеган
Approved revision: no longer in the source branch.
Merged at revision: 12728
Proposed branch: lp:~danilo/launchpad/revert-xss-workaround
Merge into: lp:launchpad
Diff against target: 167 lines (+1/-98)
5 files modified
lib/lp/bugs/browser/tests/test_bugsubscriptionfilter.py (+0/-8)
lib/lp/bugs/model/bugsubscriptionfilter.py (+1/-17)
lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py (+0/-21)
lib/lp/registry/javascript/structural-subscription.js (+0/-12)
lib/lp/registry/javascript/tests/test_structural_subscription.js (+0/-40)
To merge this branch: bzr merge lp:~danilo/launchpad/revert-xss-workaround
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+55738@code.launchpad.net

Commit message

[r=allenap][no-qa] Revert workaround for 740640 that we don't need anymore.

Description of the change

= Revert XSS fix for 740640 =

Bug 740640 fix was unnecessary since in the meantime lazr.restful has been changed to provide the fix automatically.

== Proposed fix ==

Revert parts of that branch that we don't need anymore. We only leave tags-validation in the subscription overlay.

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/bugs/browser/tests/test_bugsubscriptionfilter.py
  lib/lp/bugs/model/bugsubscriptionfilter.py
  lib/lp/registry/javascript/tests/test_structural_subscription.js
  lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py
  lib/lp/registry/javascript/structural-subscription.js

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/browser/tests/test_bugsubscriptionfilter.py'
2--- lib/lp/bugs/browser/tests/test_bugsubscriptionfilter.py 2011-03-29 10:52:55 +0000
3+++ lib/lp/bugs/browser/tests/test_bugsubscriptionfilter.py 2011-03-31 11:57:30 +0000
4@@ -183,14 +183,6 @@
5 self.assertEqual(
6 u"It's late.", self.subscription_filter.description)
7
8- def test_modify_description_xss_safeguard(self):
9- # The description can be modified but raises an
10- # exception if you try potential XSS attack characters.
11- self.ws_subscription_filter.description = u"&gt; <>"
12- error = self.assertRaises(
13- BadRequest, self.ws_subscription_filter.lp_save)
14- self.assertEqual(400, error.response.status)
15-
16 def test_modify_statuses(self):
17 # The statuses field can be modified.
18 self.assertEqual(set(), self.subscription_filter.statuses)
19
20=== modified file 'lib/lp/bugs/model/bugsubscriptionfilter.py'
21--- lib/lp/bugs/model/bugsubscriptionfilter.py 2011-03-29 10:52:55 +0000
22+++ lib/lp/bugs/model/bugsubscriptionfilter.py 2011-03-31 11:57:30 +0000
23@@ -22,7 +22,6 @@
24 from canonical.database.sqlbase import sqlvalues
25 from canonical.launchpad import searchbuilder
26 from canonical.launchpad.interfaces.lpstorm import IStore
27-from lazr.restful.error import expose
28 from lp.bugs.enum import BugNotificationLevel
29 from lp.bugs.interfaces.bugsubscriptionfilter import IBugSubscriptionFilter
30 from lp.bugs.interfaces.bugtask import (
31@@ -63,22 +62,7 @@
32
33 other_parameters = Unicode()
34
35- _description = Unicode('description')
36-
37- def _get_description(self):
38- return self._description
39-
40- def _set_description(self, description):
41- has_html_chars = (
42- '<' in description or '>' in description or
43- '"' in description or '&' in description)
44- if has_html_chars:
45- raise expose(ValueError(
46- 'BugSubscriptionFilter description cannot contain '
47- 'any of <, >, " or &.'))
48- self._description = description
49-
50- description = property(_get_description, _set_description)
51+ description = Unicode('description')
52
53 def _get_statuses(self):
54 """Return a frozenset of statuses to filter on."""
55
56=== modified file 'lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py'
57--- lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py 2011-03-29 10:52:55 +0000
58+++ lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py 2011-03-31 11:57:30 +0000
59@@ -76,27 +76,6 @@
60 bug_subscription_filter.description = u"foo"
61 self.assertEqual(u"foo", bug_subscription_filter.description)
62
63- def test_description_xss_safeguard_tags(self):
64- """Test that description property disallows a HTML tags."""
65- bug_subscription_filter = BugSubscriptionFilter()
66- self.assertRaises(ValueError,
67- setattr, bug_subscription_filter, 'description',
68- u'<script>')
69-
70- def test_description_xss_safeguard_ampersand(self):
71- """description property disallows a few HTML characters."""
72- bug_subscription_filter = BugSubscriptionFilter()
73- self.assertRaises(ValueError,
74- setattr, bug_subscription_filter, 'description',
75- u'test & blow up')
76-
77- def test_description_xss_safeguard_quote(self):
78- """description property disallows a few HTML characters."""
79- bug_subscription_filter = BugSubscriptionFilter()
80- self.assertRaises(ValueError,
81- setattr, bug_subscription_filter, 'description',
82- u'test "double" quotes')
83-
84 def test_defaults(self):
85 """Test the default values of `BugSubscriptionFilter` objects."""
86 # Create.
87
88=== modified file 'lib/lp/registry/javascript/structural-subscription.js'
89--- lib/lp/registry/javascript/structural-subscription.js 2011-03-30 11:36:37 +0000
90+++ lib/lp/registry/javascript/structural-subscription.js 2011-03-31 11:57:30 +0000
91@@ -268,7 +268,6 @@
92
93 function setup_overlay_validators(overlay, overlay_id) {
94 overlay.field_validators = {
95- name: get_error_for_subscription_name,
96 tags: get_error_for_tags_list
97 };
98 overlay.field_errors = {};
99@@ -862,17 +861,6 @@
100 });
101 };
102
103-function get_error_for_subscription_name(value) {
104- if (value.search(/[\<\>\"\&]/) == -1) {
105- return null;
106- } else {
107- return ('Subscription name cannot contain any of the following ' +
108- 'characters: &lt; &gt; &quot; &amp;');
109- }
110-};
111-// Export for testing
112-namespace._get_error_for_subscription_name = get_error_for_subscription_name;
113-
114 function get_error_for_tags_list(value) {
115 // See database/schema/trusted.sql valid_name() function
116 // which is used to validate a single tag.
117
118=== modified file 'lib/lp/registry/javascript/tests/test_structural_subscription.js'
119--- lib/lp/registry/javascript/tests/test_structural_subscription.js 2011-03-30 11:36:37 +0000
120+++ lib/lp/registry/javascript/tests/test_structural_subscription.js 2011-03-31 11:57:30 +0000
121@@ -252,46 +252,6 @@
122
123 },
124
125- test_get_error_for_subscription_name_valid: function() {
126- // Valid name makes get_error_for_subscription_name return null.
127- var name = 'Test + name!';
128- Assert.isNull(module._get_error_for_subscription_name(name));
129- },
130-
131- assertHasErrorInSubscriptionName: function(subscription_name) {
132- var error_text = module._get_error_for_subscription_name(
133- subscription_name);
134- Assert.isNotNull(error_text);
135- Assert.areEqual(
136- 'Subscription name cannot contain any of the following ' +
137- 'characters: &lt; &gt; &quot; &amp;',
138- error_text);
139- },
140-
141- test_get_error_for_subscription_name_left_angle_bracket: function() {
142- // For invalid names get_error_for_subscription_name returns
143- // an error message instead.
144- this.assertHasErrorInSubscriptionName('<Test');
145- },
146-
147- test_get_error_for_subscription_name_right_angle_bracket: function() {
148- // For invalid names get_error_for_subscription_name returns
149- // an error message instead.
150- this.assertHasErrorInSubscriptionName('Test>');
151- },
152-
153- test_get_error_for_subscription_name_ampersand: function() {
154- // For invalid names get_error_for_subscription_name returns
155- // an error message instead.
156- this.assertHasErrorInSubscriptionName('Test & fail');
157- },
158-
159- test_get_error_for_subscription_name_quote: function() {
160- // For invalid names get_error_for_subscription_name returns
161- // an error message instead.
162- this.assertHasErrorInSubscriptionName('Test "failure"');
163- },
164-
165 test_get_error_for_tags_list_valid: function() {
166 // Valid tags list is a space-separated list of tags
167 // consisting of all lowercase and digits and potentially