0001-wcs-don-t-escape-result-of-card-cell-custom-fields-6.patch
combo/apps/wcs/models.py | ||
---|---|---|
1302 | 1302 |
return extra_context |
1303 | 1303 | |
1304 | 1304 |
extra_context['card'] = card_data |
1305 |
custom_context = Context(extra_context) |
|
1305 |
custom_context = Context(extra_context, autoescape=False)
|
|
1306 | 1306 |
custom_context.update(context) |
1307 | 1307 |
repeat_index = getattr(self, 'repeat_index', context.get('repeat_index')) or 0 |
1308 | 1308 |
custom_context['repeat_index'] = repeat_index |
tests/test_wcs.py | ||
---|---|---|
141 | 141 |
'fieldb': True, |
142 | 142 |
'fieldc': '2020-09-28', |
143 | 143 |
'fieldd': {'filename': 'file.pdf', 'url': 'http://127.0.0.1:8999/download?f=42'}, |
144 |
'fielde': 'lorem<strong>ipsum\n\nhello world',
|
|
144 |
'fielde': "lorem<strong>ipsum\n\nhello'world",
|
|
145 | 145 |
'fieldf': 'lorem<strong>ipsum\n\nhello world', |
146 | 146 |
'fieldg': 'test@localhost', |
147 | 147 |
'fieldh': 'https://www.example.net/', |
... | ... | |
2553 | 2553 |
) |
2554 | 2554 |
assert ( |
2555 | 2555 |
PyQuery(result).find('.label:contains("Field E") + .value p:last-child').text().strip() |
2556 |
== 'hello world'
|
|
2556 |
== "hello'world"
|
|
2557 | 2557 |
) |
2558 | 2558 | |
2559 | 2559 |
# field F is put in a <pre> |
... | ... | |
2721 | 2721 |
result = cell.render(context) |
2722 | 2722 |
assert PyQuery(result).find('.label').text() == 'Field E' |
2723 | 2723 |
assert PyQuery(result).find('.value p:first-child').text().strip() == 'lorem<strong>ipsum' |
2724 |
assert PyQuery(result).find('.value p:last-child').text().strip() == 'hello world'
|
|
2724 |
assert PyQuery(result).find('.value p:last-child').text().strip() == "hello'world"
|
|
2725 | 2725 | |
2726 | 2726 |
cell.custom_schema['cells'][0] = { |
2727 | 2727 |
'varname': 'fieldf', |
... | ... | |
2861 | 2861 |
carddef_reference='default:card_model_1', |
2862 | 2862 |
custom_schema={ |
2863 | 2863 |
'cells': [ |
2864 |
{'varname': '@custom@', 'template': '<b>Foo</b> bar baz', 'display_mode': 'title'}, |
|
2864 |
{ |
|
2865 |
'varname': '@custom@', |
|
2866 |
'template': "<b>Foo</b> bar'baz {{ card.fields.fielde }}", |
|
2867 |
'display_mode': 'title', |
|
2868 |
}, |
|
2865 | 2869 |
] |
2866 | 2870 |
}, |
2867 | 2871 |
) |
... | ... | |
2874 | 2878 | |
2875 | 2879 |
result = cell.render(context) |
2876 | 2880 |
assert '<b>Foo</b>' in result |
2877 |
assert PyQuery(result).find('h3').text() == '<b>Foo</b> bar baz'
|
|
2881 |
assert PyQuery(result).find('h3').text() == "<b>Foo</b> bar'baz lorem<strong>ipsum hello'world"
|
|
2878 | 2882 | |
2879 | 2883 |
# test context |
2880 | 2884 |
cell.custom_schema['cells'][0][ |
2881 |
- |