Skip to content

Commit

Permalink
Merge pull request #3206 from cb1kenobi/timob-11451
Browse files Browse the repository at this point in the history
[TIMOB-11451] Fixed debug host validation to allow an empty host and por...
  • Loading branch information
cb1kenobi committed Oct 14, 2012
2 parents 332125e + e6863f9 commit 10abc19
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions iphone/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,24 +447,27 @@ exports.validate = function (logger, config, cli) {
logger.log(__('The debug host must be in the format "host:port".') + '\n');
process.exit(1);
}

var parts = cli.argv['debug-host'].split(':'),
port = parts.length > 1 && parseInt(parts[1]);
if ((cli.argv.target == 'simulator' && parts.length < 2) || (cli.argv.target != 'simulator' && parts.length < 3)) {
var parts = cli.argv['debug-host'].split(':');

if ((cli.argv.target == 'simulator' && parts.length < 2) || (cli.argv.target != 'simulator' && parts.length < 4)) {
logger.error(__('Invalid debug host "%s"', cli.argv['debug-host']) + '\n');
if (cli.argv.target == 'simulator') {
logger.log(__('The debug host must be in the format "host:port".') + '\n');
} else {
logger.log(__('The debug host must be in the format "host:port:airkey".') + '\n');
logger.log(__('The debug host must be in the format "host:port:airkey:hosts".') + '\n');
}
process.exit(1);
}
if (isNaN(port) || port < 1 || port > 65535) {
logger.error(__('Invalid debug host "%s"', cli.argv['debug-host']) + '\n');
logger.log(__('The port must be a valid integer between 1 and 65535.') + '\n');
process.exit(1);

if (parts.length > 1 && parts[1]) {
var port = parseInt(parts[1]);
if (isNaN(port) || port < 1 || port > 65535) {
logger.error(__('Invalid debug host "%s"', cli.argv['debug-host']) + '\n');
logger.log(__('The port must be a valid integer between 1 and 65535.') + '\n');
process.exit(1);
}
}
cli.argv['debug-host'] = parts.map(function (p) { return p.trim(); }).join(':');
}
};

Expand Down

0 comments on commit 10abc19

Please sign in to comment.