Patch statSyncNoException to handle non-string args

Non-string values were being coerced to strings which can cause
unexpected results.

Refs atom/atom-shell#843
Closes #4247
Esse commit está contido em:
Kevin Sawicki
2014-11-20 11:01:16 -08:00
commit 7b4a9aa2e4
2 arquivos alterados com 28 adições e 0 exclusões
+10
Ver Arquivo
@@ -13,6 +13,16 @@ process.on 'uncaughtException', (error={}) ->
nslog(error.message) if error.message?
nslog(error.stack) if error.stack?
# Patch fs.statSyncNoException/fs.lstatSyncNoException to fail for non-strings
# https://github.com/atom/atom-shell/issues/843
{lstatSyncNoException, statSyncNoException} = fs
fs.statSyncNoException = (pathToStat) ->
return false unless pathToStat and typeof pathToStat is 'string'
statSyncNoException(pathToStat)
fs.lstatSyncNoException = (pathToStat) ->
return false unless pathToStat and typeof pathToStat is 'string'
lstatSyncNoException(pathToStat)
start = ->
if process.platform is 'win32'
SquirrelUpdate = require './squirrel-update'
+18
Ver Arquivo
@@ -2,8 +2,26 @@ window.onload = function() {
try {
var startTime = Date.now();
var fs = require('fs');
var path = require('path');
// Patch fs.statSyncNoException/fs.lstatSyncNoException to fail for non-strings
// https://github.com/atom/atom-shell/issues/843
var statSyncNoException = fs.statSyncNoException;
var lstatSyncNoException = fs.lstatSyncNoException;
fs.statSyncNoException = function(pathToStat) {
if (pathToStat && typeof pathToStat === 'string')
return statSyncNoException(pathToStat);
else
return false;
};
fs.lstatSyncNoException = function(pathToStat) {
if (pathToStat && typeof pathToStat === 'string')
return lstatSyncNoException(pathToStat);
else
return false;
};
// Skip "?loadSettings=".
var loadSettings = JSON.parse(decodeURIComponent(location.search.substr(14)));