Projet

Général

Profil

0001-search-ignore-links-depending-on-cards-forms-request.patch

Frédéric Péters, 05 décembre 2022 17:47

Télécharger (1,68 ko)

Voir les différences:

Subject: [PATCH] search: ignore links depending on cards/forms/request
 (#71992)

 combo/data/models.py | 4 ++++
 tests/test_search.py | 8 ++++++++
 2 files changed, 12 insertions(+)
combo/data/models.py
1784 1784
    def get_external_links_data(self):
1785 1785
        if not self.url:
1786 1786
            return []
1787
        if re.search(r'{{.*(request\.|cards\||forms\|)', self.url):
1788
            # skip URL templates that would reference request or the cards or forms
1789
            # context processor variables.
1790
            return []
1787 1791
        link_data = self.get_cell_extra_context({})
1788 1792
        if link_data.get('title') and link_data.get('url'):
1789 1793
            return [link_data]
tests/test_search.py
592 592
        url='http://example.org/',
593 593
        order=1,
594 594
    )
595
    with mock.patch('combo.data.models.LinkCell.check_validity'):  # validity check would fail, skip it.
596
        LinkCell.objects.create(
597
            page=page,
598
            placeholder=cell.link_placeholder,
599
            title='Example 3 Site',
600
            url='http://example.org/{{ cards|objects:"foo"|filter_by_user:request.user|first|get:"id" }}',
601
            order=1,
602
        )
595 603

  
596 604
    index_site()
597 605

  
598
-