Netsapiens export; check URLs for validity. (#14919)
[freeside.git] / FS / FS / part_export / netsapiens.pm
index 867c19a..b30951d 100644 (file)
@@ -5,6 +5,7 @@ use MIME::Base64;
 use Tie::IxHash;
 use FS::part_export;
 use Date::Format qw( time2str );
+use Regexp::Common qw/URI/;
 
 @ISA = qw(FS::part_export);
 $me = '[FS::part_export::netsapiens]';
@@ -80,6 +81,22 @@ END
 
 sub rebless { shift; }
 
+
+sub check_options {
+       my ($self, $options) = @_;
+       
+       my $rex = qr/$RE{URI}{HTTP}{-scheme => qr|https?|}/;                    # match any "http:" or "https:" URL
+       
+       for my $key (qw/url device_url/) {
+               if ($$options{$key} && ($$options{$key} !~ $rex)) {
+                               return "Invalid (URL): " . $$options{$key};
+               }
+       }
+       return '';
+}
+
+
+
 sub ns_command {
   my $self = shift;
   $self->_ns_command('', @_);