Projet

Général

Profil

0001-misc-set-response.content-as-bytes-as-appropriate-67.patch

Frédéric Péters, 07 juillet 2022 15:23

Télécharger (1,75 ko)

Voir les différences:

Subject: [PATCH] misc: set response.content as bytes, as appropriate (#67137)

 combo/public/views.py | 4 ++--
 tests/test_public.py  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
combo/public/views.py
364 364

  
365 365
    template_name = combo_template['template']
366 366
    response = render(request, template_name, ctx)
367
    response.content = '{%% with page_template_name="%s" %%}%s{%% endwith %%}' % (
368
        str(selected_page.template_name),
367
    response.content = b'{%% with page_template_name="%s" %%}%s{%% endwith %%}' % (
368
        selected_page.template_name.encode(),
369 369
        response.content,
370 370
    )
371 371
    response['X-Combo-Page-Id'] = str(selected_page.id)
tests/test_public.py
341 341
    resp = app.get('/__skeleton__/?source=%s' % quote('http://example.net/foo/bar'))
342 342
    assert '{% block placeholder-content %}{% block content %}{% endblock %}{% endblock %}' in resp.text
343 343
    assert '{% block placeholder-footer %}{% block footer %}{% endblock %}{% endblock %}' in resp.text
344
    assert resp.text.startswith('{% with page_template_name="standard" %}')
344
    assert resp.text.startswith('{% with page_template_name="standard" %}<!DOCTYPE html>\n')
345 345

  
346 346
    # url netloc match
347 347
    resp = app.get('/__skeleton__/?source=%s' % quote('http://example.net'))
348
-