Fields in Device Details in UI need escaping for SQL query #918
Labels
bug 🐛
Something isn't working
next release/in dev image🚀
This is coming in the next release or was already released if the issue is Closed.
Is there an existing issue for this?
The issue occurs in the following browsers. Select at least 2.
Current Behavior
"Error executing query (attempts: 10), query: UPDATE Devices SET\n devName = 'X20-DSL',\n devOwner = 'System',\n devType = 'Router',\n devVendor = 'TP-Link Limited',\n devIcon = '',\n devFavorite = '0',\n devGroup = 'System',\n devLocation = 'Ingo's Office',\n devComments = 'New Device',\n devParentMAC = 'Internet',\n devParentPort = '0',\n devSSID = '',\n devSite = '',\n devStaticIP = '0',\n devScan = '1',\n devAlertEvents = '0',\n devAlertDown = '0',\n devSkipRepeated = '1',\n devIsNew = '0',\n devIsArchived = '0'\n WHERE devMac = '28:87:ba:8a:6c:d0'"
Expected Behavior
UPDATE Devices SET\n devName = 'X20-DSL',\n devOwner = 'System',\n devType = 'Router',\n devVendor = 'TP-Link Limited',\n devIcon = '',\n devFavorite = '0',\n devGroup = 'System',\n devLocation = 'Ingo's Office',\n devComments = 'New Device',\n devParentMAC = 'Internet',\n devParentPort = '0',\n devSSID = '',\n devSite = '',\n devStaticIP = '0',\n devScan = '1',\n devAlertEvents = '0',\n devAlertDown = '0',\n devSkipRepeated = '1',\n devIsNew = '0',\n devIsArchived = '0'\n WHERE devMac = '28:87:ba:8a:6c:d0'"
Steps To Reproduce
Open device details page /deviceDetails.php?mac=28:87:ba:8a:6c:d0 and enter a name with a single quote " ' " as location.
SQL times out with error above upon save.
Looks like in EditDeviceDetails.php, name , owner and vendor are having any " ' " removed, but locations (and other fields) have not.
+ '&name=' + encodeURIComponent($('#NEWDEV_devName').val().replace(/'/g, ""))
+ '&owner=' + encodeURIComponent($('#NEWDEV_devOwner').val().replace(/'/g, ""))
+ '&type=' + $('#NEWDEV_devType').val()
+ '&vendor=' + encodeURIComponent($('#NEWDEV_devVendor').val().replace(/'/g, ""))
+ '&icon=' + encodeURIComponent($('#NEWDEV_devIcon').val())
+ '&favorite=' + ($('#NEWDEV_devFavorite')[0].checked * 1)
+ '&group=' + encodeURIComponent($('#NEWDEV_devGroup').val())
+ '&location=' + encodeURIComponent($('#NEWDEV_devLocation').val())
app.conf
No response
docker-compose.yml
No response
What branch are you running?
Production
app.log
No response
Debug enabled
The text was updated successfully, but these errors were encountered: