1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

Fixed: Proper port validation for download clients and connections

Closes #1642
This commit is contained in:
Mark McDowall 2017-01-26 22:35:16 -08:00
parent 3bd7c09acf
commit ef03e9e9a7
14 changed files with 17 additions and 17 deletions

View File

@ -73,14 +73,14 @@ public static object ReadFromSchema(List<Field> fields, Type targetType)
if (propertyInfo.PropertyType == typeof(int))
{
var value = Convert.ToInt32(field.Value);
propertyInfo.SetValue(target, value, null);
var value = field.Value.ToString().ParseInt32();
propertyInfo.SetValue(target, value ?? 0, null);
}
else if (propertyInfo.PropertyType == typeof(long))
{
var value = Convert.ToInt64(field.Value);
propertyInfo.SetValue(target, value, null);
var value = field.Value.ToString().ParseInt64();
propertyInfo.SetValue(target, value ?? 0, null);
}
else if (propertyInfo.PropertyType == typeof(int?))

View File

@ -10,7 +10,7 @@ public class DelugeSettingsValidator : AbstractValidator<DelugeSettings>
public DelugeSettingsValidator()
{
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.Port).GreaterThan(0);
RuleFor(c => c.Port).InclusiveBetween(1, 65535);
RuleFor(c => c.TvCategory).Matches("^[-a-z]*$").WithMessage("Allowed characters a-z and -");
}

View File

@ -10,7 +10,7 @@ public class HadoukenSettingsValidator : AbstractValidator<HadoukenSettings>
public HadoukenSettingsValidator()
{
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.Port).GreaterThan(0);
RuleFor(c => c.Port).InclusiveBetween(1, 65535);
RuleFor(c => c.Username).NotEmpty()
.WithMessage("Username must not be empty.");

View File

@ -10,7 +10,7 @@ public class NzbVortexSettingsValidator : AbstractValidator<NzbVortexSettings>
public NzbVortexSettingsValidator()
{
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.Port).GreaterThan(0);
RuleFor(c => c.Port).InclusiveBetween(1, 65535);
RuleFor(c => c.ApiKey).NotEmpty()
.WithMessage("API Key is required");

View File

@ -10,7 +10,7 @@ public class NzbgetSettingsValidator : AbstractValidator<NzbgetSettings>
public NzbgetSettingsValidator()
{
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.Port).GreaterThan(0);
RuleFor(c => c.Port).InclusiveBetween(1, 65535);
RuleFor(c => c.Username).NotEmpty().When(c => !string.IsNullOrWhiteSpace(c.Password));
RuleFor(c => c.Password).NotEmpty().When(c => !string.IsNullOrWhiteSpace(c.Username));

View File

@ -10,7 +10,7 @@ public class QBittorrentSettingsValidator : AbstractValidator<QBittorrentSetting
public QBittorrentSettingsValidator()
{
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.Port).InclusiveBetween(0, 65535);
RuleFor(c => c.Port).InclusiveBetween(1, 65535);
}
}

View File

@ -10,7 +10,7 @@ public class SabnzbdSettingsValidator : AbstractValidator<SabnzbdSettings>
public SabnzbdSettingsValidator()
{
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.Port).GreaterThan(0);
RuleFor(c => c.Port).InclusiveBetween(1, 65535);
RuleFor(c => c.ApiKey).NotEmpty()
.WithMessage("API Key is required when username/password are not configured")

View File

@ -12,7 +12,7 @@ public class TransmissionSettingsValidator : AbstractValidator<TransmissionSetti
public TransmissionSettingsValidator()
{
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.Port).GreaterThan(0);
RuleFor(c => c.Port).InclusiveBetween(1, 65535);
RuleFor(c => c.UrlBase).ValidUrlBase();

View File

@ -10,7 +10,7 @@ public class RTorrentSettingsValidator : AbstractValidator<RTorrentSettings>
public RTorrentSettingsValidator()
{
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.Port).InclusiveBetween(0, 65535);
RuleFor(c => c.Port).InclusiveBetween(1, 65535);
RuleFor(c => c.TvCategory).NotEmpty()
.WithMessage("A category is recommended")
.AsWarning();

View File

@ -10,7 +10,7 @@ public class UTorrentSettingsValidator : AbstractValidator<UTorrentSettings>
public UTorrentSettingsValidator()
{
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.Port).InclusiveBetween(0, 65535);
RuleFor(c => c.Port).InclusiveBetween(1, 65535);
RuleFor(c => c.TvCategory).NotEmpty();
}
}

View File

@ -10,7 +10,7 @@ public class EmailSettingsValidator : AbstractValidator<EmailSettings>
public EmailSettingsValidator()
{
RuleFor(c => c.Server).NotEmpty();
RuleFor(c => c.Port).GreaterThan(0);
RuleFor(c => c.Port).InclusiveBetween(1, 65535);
RuleFor(c => c.From).NotEmpty();
RuleFor(c => c.To).NotEmpty();
}

View File

@ -10,7 +10,7 @@ public class GrowlSettingsValidator : AbstractValidator<GrowlSettings>
public GrowlSettingsValidator()
{
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.Port).GreaterThan(0);
RuleFor(c => c.Port).InclusiveBetween(1, 65535);
}
}

View File

@ -10,7 +10,7 @@ public class PlexClientSettingsValidator : AbstractValidator<PlexClientSettings>
public PlexClientSettingsValidator()
{
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.Port).GreaterThan(0);
RuleFor(c => c.Port).InclusiveBetween(1, 65535);
}
}

View File

@ -10,7 +10,7 @@ public class PlexServerSettingsValidator : AbstractValidator<PlexServerSettings>
public PlexServerSettingsValidator()
{
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.Port).GreaterThan(0);
RuleFor(c => c.Port).InclusiveBetween(1, 65535);
}
}