diff options
author | Bobby Holley <bobbyholley@gmail.com> | 2011-11-29 21:33:21 -0800 |
---|---|---|
committer | Chris Cormack <chris@bigballofwax.co.nz> | 2013-06-24 20:00:19 +1200 |
commit | 8c3331d5f4a6cd52190998fbb6c0785c261fc382 (patch) | |
tree | edd3f226764e420f5533acbd60d5536d13c14acf | |
parent | a97cc2c319c5364b56d17ddf1218a2a6a0dac042 (diff) | |
download | git-bz-8c3331d5f4a6cd52190998fbb6c0785c261fc382.tar.gz |
Use the CSRF token from the attachment page, rather than the bug page, when attaching files.
This fixes breakage caused by a recent BMO change.
A similar change was made to bzapi: http://hg.mozilla.org/webtools/bzapi/rev/5ca3562f2e6c
-rwxr-xr-x | git-bz | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -1178,6 +1178,18 @@ class Bug(object): if error != None: die ("Failed to retrieve bug information: %s" % error) + # Bugzilla now requires a separate token from the attachment creation + # page to create an attachment. There doesn't appear to be an XML + # interface to it, so we scrape away. + attachment_url = "/attachment.cgi?bugid=" + id + "&action=enter" + attachment_response = self.server.send_request("GET", attachment_url) + self.attachment_token = None + if response.status == 200: + attachment_match = re.search(r'name="token" value="([^"]+)', + attachment_response.read()) + if attachment_match: + self.attachment_token = attachment_match.group(1) + self.id = int(bug.find("bug_id").text) self.short_desc = bug.find("short_desc").text self.bug_status = bug.find("bug_status").text @@ -1286,6 +1298,8 @@ class Bug(object): def create_patch(self, description, comment, filename, data, obsoletes=[], status='none'): fields = {} fields['bugid'] = str(self.id) + if self.attachment_token: + fields['token'] = self.attachment_token fields['action'] = 'insert' fields['ispatch'] = '1' fields['attachments.status'] = status |