From 2b92e1805f05b40e8a1eaae7c9476e1447fb00d4 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 12 Oct 2016 09:07:07 +0200 Subject: [PATCH] osc: sanitize typetag before sending --- CHANGELOG.md | 7 ++++++- app/main/osc.js | 13 ++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc88f72e..2a4c7823 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## next + +- bug + - avoid crash when sending osc with incorrect typetags + ## 0.8.1 - bug @@ -21,7 +26,7 @@ - removed special `false` value case for push/toggles (which used to disable osc sending) - add `norelease` option to `push` for disabling osc messages when releasing the button - `true` and `false` values are now properly sent as boolean - - **args type definition** in `preArgs` option now uses the osc typetags only ('f', 'i', 'T', 'F', etc) + - **args type definition** in `preArgs` option now uses the osc typetags only ('f', 'i', 'T', 'F', etc) - engine - electron 1.4.3 - misc diff --git a/app/main/osc.js b/app/main/osc.js index 1481bf86..96a14971 100644 --- a/app/main/osc.js +++ b/app/main/osc.js @@ -28,6 +28,17 @@ oscServer.on('error', function (error) { oscServer.open() +var parseType = function(type){ + var t = type[0].match(/[bhtdscrmTFNI]/) + + if (t!==null) { + return t[0] + } else { + return 's' + } + +} + var parseArg = function(arg,precision){ if (arg==null) return null switch (typeof arg) { @@ -36,7 +47,7 @@ var parseArg = function(arg,precision){ case 'boolean': return {type: arg ? 'T' : 'F', value: arg} case 'object': - return {type: arg.type, value: arg.value} + return {type: parseType(arg.type), value: arg.value} default: return {type: 'string', value:String(arg)} }