Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-11451] Fixed debug host validation to allow an empty host and por... #3206

Merged
merged 1 commit into from
Oct 14, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 13 additions & 10 deletions iphone/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,24 +446,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