wellsjo / JSON-Splora

GUI app for editing, visualizing, and manipulating JSON data
MIT License
1.86k stars 60 forks source link

js evaluate result check bug #35

Closed qifuren1985 closed 7 years ago

qifuren1985 commented 7 years ago

In Editor.js, line 166 has a bug. if result is empty string or 0, it will run through jq. if (context.result) { ..... } should be if (context.result != undefined) { ..... }

test code: if(""){alert(1)} //nothing happen if(0){alert(1)} //nothing happen if("1"){alert(1)} // will alert

MaanooAk commented 7 years ago

There are about a million places where people talk about how to check if something is undefined. I'm not even try to convice you that typeof myVar === 'undefined' is the "proper" way but if have some time to kill Google it..

EDIT: Clarification: context.result != undefined should be typeof context.result !== 'undefined'

wellsjo commented 7 years ago

@qifuren1985 is right, if result = x${filter} evaluates to something falsey, the filter is considered invalid.