Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions extension/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@
return str.join('').slice(2, -2);
}

function removeTypeofGuard(s) {
return s.replace(/^typeof \S+ === 'function' && /, '');
}

function firstJSONCharIndex(s) {
var arrayIdx = s.indexOf('['),
objIdx = s.indexOf('{'),
Expand Down Expand Up @@ -434,6 +438,7 @@

// Get the substring up to the first "(", with any comments/whitespace stripped out
var firstBit = removeComments( text.substring(0,indexOfParen) ).trim() ;
firstBit = removeTypeofGuard(firstBit);
if ( ! firstBit.match(/^[a-zA-Z_$][\.\[\]'"0-9a-zA-Z_$]*$/) ) {
// The 'firstBit' is NOT a valid function identifier.
port.postMessage(['NOT JSON', 'first bit not a valid function name']) ;
Expand Down