Modify ↓
Opened 8 years ago
Closed 8 years ago
#12592 closed defect (fixed)
Batch modify should require POST method
Reported by: | Jun Omae | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.14 |
Component: | query system | Version: | |
Severity: | normal | Keywords: | batch-modify |
Cc: | Branch: | ||
Release Notes: |
Batch modify requires POST method. |
||
API Changes: | |||
Internal Changes: |
Description
Batch modify doesn't check whether HTTP method is POST. We should require POST.
-
trac/ticket/batch.py
diff --git a/trac/ticket/batch.py b/trac/ticket/batch.py index 5fcedc4ef..464cd18af 100644
a b from trac.ticket.notification import BatchTicketNotifyEmail 28 28 from trac.util.datefmt import datetime_now, utc 29 29 from trac.util.text import exception_to_unicode, to_unicode 30 30 from trac.util.translation import _, tag_ 31 from trac.web.api import IRequestFilter, IRequestHandler 31 from trac.web.api import IRequestFilter, IRequestHandler, HTTPBadRequest 32 32 from trac.web.chrome import add_warning, add_script_data 33 33 34 34 … … class BatchModifyModule(Component): 53 53 return req.path_info == '/batchmodify' 54 54 55 55 def process_request(self, req): 56 if req.method != 'POST': 57 raise HTTPBadRequest(_("Invalid request arguments.")) 56 58 req.perm.assert_permission('TICKET_BATCH_MODIFY') 57 59 58 60 comment = req.args.get('batchmod_value_comment', '') -
trac/ticket/tests/batch.py
diff --git a/trac/ticket/tests/batch.py b/trac/ticket/tests/batch.py index c05cf765f..eff9daf0c 100644
a b from trac.ticket import default_workflow, web_ui 23 23 from trac.ticket.batch import BatchModifyModule 24 24 from trac.ticket.model import Ticket 25 25 from trac.util.datefmt import datetime_now, utc 26 from trac.web.api import HTTPBadRequest, RequestDone 26 27 from trac.web.chrome import web_context 27 28 28 29 … … class BatchModifyTestCase(unittest.TestCase): 106 107 selected_tickets = batch._get_selected_tickets(self.req) 107 108 self.assertEqual(selected_tickets, []) 108 109 110 def test_require_post_method(self): 111 batch = BatchModifyModule(self.env) 112 req = MockRequest(self.env, method='GET', path_info='/batchmodify') 113 self.assertTrue(batch.match_request(req)) 114 self.assertRaises(HTTPBadRequest, batch.process_request, req) 115 req = MockRequest(self.env, method='POST', path_info='/batchmodify', 116 args={'selected_tickets': ''}) 117 self.assertTrue(batch.match_request(req)) 118 self.assertRaises(RequestDone, batch.process_request, req) 119 109 120 # Assign list items 110 121 111 122 def test_change_list_replace_empty_with_single(self):
Attachments (0)
Change History (2)
comment:1 by , 8 years ago
Component: | ticket system → query system |
---|---|
Owner: | set to |
Status: | new → assigned |
comment:2 by , 8 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
Committed in [15160] and merged in [15161-15162].