Projet

Général

Profil

0002-deprecations-add-detection-of-python-expression-in-a.patch

Frédéric Péters, 20 juin 2022 10:45

Télécharger (2,21 ko)

Voir les différences:

Subject: [PATCH 2/2] deprecations: add detection of python expression in
 attachments (#66397)

 tests/admin_pages/test_deprecations.py | 4 ++++
 wcs/backoffice/deprecations.py         | 7 +++++++
 2 files changed, 11 insertions(+)
tests/admin_pages/test_deprecations.py
125 125
    sendmail = st0.add_action('sendmail', id='_sendmail')
126 126
    sendmail.to = ['=plop']
127 127

  
128
    sendmail = st0.add_action('sendmail', id='_sendmail2')
129
    sendmail.attachments = ['python']
130

  
128 131
    display_form = st0.add_action('form', id='_x')
129 132
    display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
130 133
    display_form.formdef.fields.append(
......
199 202
        'test / New Form Creation',
200 203
        'test / User Profile Update',
201 204
        'test / Email',
205
        'test / Email',
202 206
        'Webservice "Hello"',
203 207
    ]
204 208
    assert [x.text for x in resp.pyquery('.section--script li a')] == [
wcs/backoffice/deprecations.py
190 190
                    else:
191 191
                        if kind == 'rtf':
192 192
                            self.add_report_line(location_label=location_label, url=url, category='rtf')
193
                if action.key in ('register-comment', 'sendmail'):
194
                    for attachment in getattr(action, 'attachments', None) or []:
195
                        if attachment and not ('{%' in attachment or '{{' in attachment):
196
                            self.add_report_line(
197
                                location_label=location_label, url=url, category='python-expression'
198
                            )
199
                            break
193 200

  
194 201
            self.increment_count()
195 202

  
196
-