From f36306ceea141e4ff6a2af2c1c0adea90754b8f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 7 Jun 2020 18:08:17 +0200 Subject: [PATCH] dataviz: don't crash on missing width value (#43726) --- combo/apps/dataviz/views.py | 4 ++-- tests/test_dataviz.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/combo/apps/dataviz/views.py b/combo/apps/dataviz/views.py index a9955a01..cf319e08 100644 --- a/combo/apps/dataviz/views.py +++ b/combo/apps/dataviz/views.py @@ -41,8 +41,8 @@ def dataviz_graph(request, *args, **kwargs): error_text = None try: chart = cell.get_chart( - width=int(request.GET.get('width', 0)) or None, - height=int(request.GET.get('height', 0)) or int(cell.height) + width=int(request.GET['width']) if request.GET.get('width') else None, + height=int(request.GET['height']) if request.GET.get('height') else int(cell.height) ) except UnsupportedDataSet as e: error_text = _('Unsupported dataset.') diff --git a/tests/test_dataviz.py b/tests/test_dataviz.py index 6fc01251..3854569b 100644 --- a/tests/test_dataviz.py +++ b/tests/test_dataviz.py @@ -380,6 +380,9 @@ def test_chartng_cell_view(app, normal_user): resp = app.get('/api/dataviz/graph/1/?width=400') assert resp.content_type == 'image/svg+xml' + resp = app.get('/api/dataviz/graph/1/?width=') # no crash + assert resp.content_type == 'image/svg+xml' + page.public = False page.save() resp = app.get('/api/dataviz/graph/1/?width=400', status=403)