Projet

Général

Profil

« Précédent | Suivant » 

Révision d17392b7

Ajouté par Serghei Mihai il y a presque 8 ans

don't show identifier's scheme on unsubscription page (#12544)

Voir les différences:

corbo/models.py
121 121
    uuid = models.CharField(_('User identifier'), max_length=128, blank=True)
122 122
    identifier = models.CharField(_('identifier'), max_length=128, blank=True,
123 123
            help_text=_('ex.: mailto, homepage, ...'))
124

  
125
    def get_identifier_display(self):
126
        try:
127
            scheme, identifier = self.identifier.split(':')
128
            return identifier
129
        except ValueError:
130
            return self.identifier
131

  
124 132
    class Meta:
125 133
        unique_together = ('category', 'identifier', 'uuid')
corbo/templates/corbo/subscription_confirm_delete.html
7 7

  
8 8
{% block content %}
9 9
<div class="unsubscription">
10
{% blocktrans with object.category as category and object.identifier as identifier %}
10
{% blocktrans with object.category as category and object.get_identifier_display as identifier %}
11 11
Are you sure you want to unsubscribe {{ identifier }} from "{{ category }}"?
12 12
{% endblocktrans %}
13 13
<form method='POST'>
corbo/views.py
119 119
        data = signing.loads(self.kwargs['unsubscription_token'])
120 120
        try:
121 121
            return models.Subscription.objects.get(category__pk=data['category'],
122
                                identifier=data['identifier'])
122
                                        identifier=data['identifier'])
123 123
        except models.Subscription.DoesNotExist:
124 124
            raise Http404
125 125

  
tests/test_emailing.py
96 96
def test_unsubscription_link(app, categories, announces):
97 97
    for category in categories:
98 98
        uuid = uuid4()
99
        email = '%s@example.net' % uuid
99
        scheme = 'mailto:'
100
        uri = scheme + '%s@example.net' % uuid
100 101
        s = Subscription.objects.create(category=category,
101
                                identifier=email,
102
                                identifier=uri,
102 103
                                uuid=str(uuid))
103 104
        for announce in announces:
104 105
            if announce.category != category:
......
108 109
            assert broadcast.result
109 110
            assert mail.outbox
110 111
            signature = signing.dumps({'category': announce.category.pk,
111
                                       'identifier': email})
112
                                       'identifier': uri})
112 113
            unsubscription_link = reverse('unsubscribe', kwargs={'unsubscription_token': signature})
113 114
            assert mail.outbox[0].subject == announce.title
114 115
            assert unsubscription_link in mail.outbox[0].html
115 116
            assert unsubscription_link in mail.outbox[0].text
116 117
            mail.outbox = []
118
            # make sure the uri schema is not in the page
119
            resp = app.get(unsubscription_link)
120
            assert scheme not in resp.content

Formats disponibles : Unified diff