OLD | NEW |
1 # This file is part of Buildbot. Buildbot is free software: you can | 1 # This file is part of Buildbot. Buildbot is free software: you can |
2 # redistribute it and/or modify it under the terms of the GNU General Public | 2 # redistribute it and/or modify it under the terms of the GNU General Public |
3 # License as published by the Free Software Foundation, version 2. | 3 # License as published by the Free Software Foundation, version 2. |
4 # | 4 # |
5 # This program is distributed in the hope that it will be useful, but WITHOUT | 5 # This program is distributed in the hope that it will be useful, but WITHOUT |
6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
8 # details. | 8 # details. |
9 # | 9 # |
10 # You should have received a copy of the GNU General Public License along with | 10 # You should have received a copy of the GNU General Public License along with |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 FAILURE: "failure", | 55 FAILURE: "failure", |
56 SKIPPED: "skipped", | 56 SKIPPED: "skipped", |
57 EXCEPTION: "exception", | 57 EXCEPTION: "exception", |
58 RETRY: "retry", | 58 RETRY: "retry", |
59 None: "", | 59 None: "", |
60 } | 60 } |
61 | 61 |
62 | 62 |
63 def getAndCheckProperties(req): | 63 def getAndCheckProperties(req): |
64 """ | 64 """ |
65 Fetch custom build properties from the HTTP request of a "Force build" or | 65 Fetch custom build properties from the HTTP request of a "Force build" or |
66 "Resubmit build" HTML form. | 66 "Resubmit build" HTML form. |
67 Check the names for valid strings, and return None if a problem is found. | 67 Check the names for valid strings, and return None if a problem is found. |
68 Return a new Properties object containing each property found in req. | 68 Return a new Properties object containing each property found in req. |
69 """ | 69 """ |
| 70 master = req.site.buildbot_service.master |
| 71 pname_validate = master.config.validation['property_name'] |
| 72 pval_validate = master.config.validation['property_value'] |
70 properties = Properties() | 73 properties = Properties() |
71 i = 1 | 74 i = 1 |
72 while True: | 75 while True: |
73 pname = req.args.get("property%dname" % i, [""])[0] | 76 pname = req.args.get("property%dname" % i, [""])[0] |
74 pvalue = req.args.get("property%dvalue" % i, [""])[0] | 77 pvalue = req.args.get("property%dvalue" % i, [""])[0] |
75 if not pname: | 78 if not pname: |
76 break | 79 break |
77 if not re.match(r'^[\w\.\-\/\~:]*$', pname) \ | 80 if not pname_validate.match(pname) \ |
78 or not re.match(r'^[\w\.\-\/\~:]*$', pvalue): | 81 or pval_validate.match(pvalue): |
79 log.msg("bad property name='%s', value='%s'" % (pname, pvalue)) | 82 log.msg("bad property name='%s', value='%s'" % (pname, pvalue)) |
80 return None | 83 return None |
81 properties.setProperty(pname, pvalue, "Force Build Form") | 84 properties.setProperty(pname, pvalue, "Force Build Form") |
82 i = i + 1 | 85 i = i + 1 |
83 | 86 |
84 return properties | 87 return properties |
85 | 88 |
86 def build_get_class(b): | 89 def build_get_class(b): |
87 """ | 90 """ |
88 Return the class to use for a finished build or buildstep, | 91 Return the class to use for a finished build or buildstep, |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 return filter | 764 return filter |
762 | 765 |
763 class AlmostStrictUndefined(jinja2.StrictUndefined): | 766 class AlmostStrictUndefined(jinja2.StrictUndefined): |
764 ''' An undefined that allows boolean testing but | 767 ''' An undefined that allows boolean testing but |
765 fails properly on every other use. | 768 fails properly on every other use. |
766 | 769 |
767 Much better than the default Undefined, but not | 770 Much better than the default Undefined, but not |
768 fully as strict as StrictUndefined ''' | 771 fully as strict as StrictUndefined ''' |
769 def __nonzero__(self): | 772 def __nonzero__(self): |
770 return False | 773 return False |
OLD | NEW |