File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -14,9 +14,10 @@ module.exports = function(RED) {
14
14
}
15
15
else if ( typeof msg . payload === "string" ) {
16
16
// Take base64 string and make into binary buffer
17
- var regexp = new RegExp ( '^[A-Za-z0-9+\/=]*$' ) ;
18
- if ( regexp . test ( msg . payload ) && ( msg . payload . length % 4 === 0 ) ) {
19
- msg . payload = new Buffer ( msg . payload , 'base64' ) ;
17
+ var load = msg . payload . replace ( / \s + / g, '' ) ; // remove any whitespace
18
+ var regexp = new RegExp ( '^[A-Za-z0-9+\/=]*$' ) ; // check it only contains valid characters
19
+ if ( regexp . test ( load ) && ( load . length % 4 === 0 ) ) {
20
+ msg . payload = new Buffer ( load , 'base64' ) ;
20
21
node . send ( msg ) ;
21
22
}
22
23
else {
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " node-red-node-base64" ,
3
- "version" : " 0.0.6 " ,
3
+ "version" : " 0.0.7 " ,
4
4
"description" : " A Node-RED node to pack and unpack objects to base64 format" ,
5
5
"dependencies" : {
6
6
},
You can’t perform that action at this time.
0 commit comments