Skip to content

Commit 1f22a16

Browse files
committed
Sanitising device names in data export code.
1 parent 9d946fb commit 1f22a16

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/www/app/main.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,9 @@ def DownloadData():
663663
df.to_csv(buffer, encoding='UTF-8')
664664
buffer.seek(0)
665665

666-
return send_file(buffer, as_attachment=True, download_name=f'{logical_dev.name}.csv')
666+
sanitised_dev_name = re.sub(r'[^a-zA-Z0-9_-]', '', logical_dev.name)
667+
668+
return send_file(buffer, as_attachment=True, download_name=f'{sanitised_dev_name}.csv')
667669

668670

669671
except requests.exceptions.HTTPError as e:

src/www/app/templates/logical_device_form.html

+2-3
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@
127127
dialog.addEventListener("close", doFetch);
128128
});
129129

130-
function exportData(l_uid, name) {
131-
console.log("exportData " + l_uid + " " + name);
130+
function exportData(l_uid) {
132131
dialog.returnValue = "Cancel";
133132
dialog.showModal();
134133

@@ -205,7 +204,7 @@ <h3 style="padding: 8px">Export data</h3>
205204
<div class="command-bar">
206205
<div class="form-buttons">
207206
<ul>
208-
<li><span class="btn" onclick="exportData('{{ ld_data.uid }}', '{{ ld_data.name}}')">Export Data</span></li>
207+
<li><span class="btn" onclick="exportData('{{ ld_data.uid }}')">Export Data</span></li>
209208
<li><span class="btn" onclick="handleSubmit('device-form', 'Are you sure you want to Save?')">Save</span></li>
210209
<li><span class="btn" onclick="handleMapping('logical device')">Update Mapping</span></li>
211210
<li><span class="btn" onclick="handleEndMapping('{{ ld_data.uid }}', 'LD')">End Mapping</span></li>

0 commit comments

Comments
 (0)