wcs: replace newlines by spaces in title and headers (#86308)
gitea/combo/pipeline/head This commit looks good
Details
gitea/combo/pipeline/head This commit looks good
Details
This commit is contained in:
parent
1e65e2ea49
commit
03361bfbb9
|
@ -1702,6 +1702,8 @@ class WcsCardCell(CardMixin, CellBase):
|
|||
if card_data.get('digests', {}).get(digest_name):
|
||||
page_title_from_cell = card_data['digests'][digest_name]
|
||||
if page_title_from_cell:
|
||||
# header values can't contain newlines
|
||||
page_title_from_cell = page_title_from_cell.replace('\n', ' ')
|
||||
custom_context['request'].page_title_from_cell = page_title_from_cell
|
||||
|
||||
def set_data_from_repeated_cell(self, cell, context):
|
||||
|
|
|
@ -2337,6 +2337,17 @@ def test_card_cell_card_mode_render(mock_send, context, app):
|
|||
resp = app.get(page.get_online_url() + '11/', headers={'User-Agent': 'testbot'})
|
||||
assert resp.pyquery('title').text() == 'afoo afoo afoo | Combo - xxx'
|
||||
|
||||
# custom-view:bar contains \n, header values can't contain newlines
|
||||
cell.carddef_reference = 'default:card_model_1:bar'
|
||||
cell.save()
|
||||
resp = app.get(page.get_online_url() + '11/')
|
||||
cell_resp = app.get(
|
||||
resp.pyquery('.wcs-card-cell').attr['data-ajax-cell-url']
|
||||
+ '?ctx='
|
||||
+ resp.pyquery('.wcs-card-cell').attr['data-extra-context']
|
||||
)
|
||||
assert cell_resp.headers['X-Page-Title'] == 'a a a' # \n are replaced by spaces
|
||||
|
||||
|
||||
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
||||
def test_card_cell_card_mode_render_text_field(mock_send, context):
|
||||
|
|
|
@ -108,7 +108,11 @@ WCS_CARDS_DATA = {
|
|||
'display_id': '10-11',
|
||||
'display_name': 'Card Model 1 - n°10-11',
|
||||
'digest': 'a a a',
|
||||
'digests': {'default': 'a a a', 'custom-view:foo': 'afoo afoo afoo'},
|
||||
'digests': {
|
||||
'default': 'a a a',
|
||||
'custom-view:foo': 'afoo afoo afoo',
|
||||
'custom-view:bar': 'a\na\na',
|
||||
},
|
||||
'text': 'aa',
|
||||
'receipt_time': '2021-11-29T14:33:37',
|
||||
'last_update_time': '2023-07-24T16:04:24',
|
||||
|
|
Loading…
Reference in New Issue