osc: sanitize typetag before sending

This commit is contained in:
jean-emmanuel 2016-10-12 09:07:07 +02:00
parent 4f502f6120
commit 2b92e1805f
2 changed files with 18 additions and 2 deletions

View file

@ -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

View file

@ -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)}
}