[Rt-commit] rt branch, 4.4/validator-asset-links, created. rt-4.4.2-100-gb6ed83265

? sunnavy sunnavy at bestpractical.com
Fri Mar 9 17:26:22 EST 2018


The branch, 4.4/validator-asset-links has been created
        at  b6ed832659da7ef6b030a003f46b55071b55471d (commit)

- Log -----------------------------------------------------------------
commit 62b9148f86315c3811762cc46becd086125199e9
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Wed Dec 14 13:53:48 2016 -0500

    Update link checking regex to match asset links
    
    Previous RT link types looked like scheme://org/ticket/42,
    but asset links look like asset://org/42. Update the regex
    match in validator to treat the 'ticket' part of the URI as
    optional. This allows the validator to detect and fix asset links
    broken due to an Organization change.

diff --git a/sbin/rt-validator.in b/sbin/rt-validator.in
index 1b0716afe..8875310d7 100644
--- a/sbin/rt-validator.in
+++ b/sbin/rt-validator.in
@@ -1057,7 +1057,7 @@ push @CHECKS, 'Links: wrong organization' => sub {
             while ( my ($id, $value) = $sth->fetchrow_array ) {
                 $res = 0;
                 print STDERR "Record #$id in $table. Value of $column column most probably is an incorrect link\n";
-                my ($wrong_org) = ( $value =~ m{^\Q$scheme\E://(.+)/[^/]+/[0-9]*$} );
+                my ($wrong_org) = ( $value =~ m{^\Q$scheme\E://(.+?)/(?:[^/]+/)*[0-9]*$} );
                 next unless my $replace_with = prompt(
                     'Replace',
                     "Column $column in $table is a link.  There is record #$id that has a"

commit b6ed832659da7ef6b030a003f46b55071b55471d
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Mar 10 06:03:12 2018 +0800

    Remove trailing "/" from RT::URI::asset::LocalURIPrefix for consistency
    
    Other objects' LocalURIPrefix don't have trailing "/". Without this
    change, rt-validator will be confused and form URIs with duplicate "/"
    like "asset://foo.com//1"

diff --git a/lib/RT/URI/asset.pm b/lib/RT/URI/asset.pm
index 538e648c7..91ed02240 100644
--- a/lib/RT/URI/asset.pm
+++ b/lib/RT/URI/asset.pm
@@ -90,7 +90,7 @@ Returns the site-specific prefix for a local asset URI
 
 sub LocalURIPrefix {
     my $self = shift;
-    return $self->Scheme . "://" . RT->Config->Get('Organization') . "/";
+    return $self->Scheme . "://" . RT->Config->Get('Organization');
 }
 
 =head2 IsLocal
@@ -103,7 +103,7 @@ undef otherwise.
 sub IsLocal {
     my $self   = shift;
     my $prefix = $self->LocalURIPrefix;
-    return $1 if $self->{uri} =~ /^\Q$prefix\E(\d+)/i;
+    return $1 if $self->{uri} =~ qr!^\Q$prefix\E/(\d+)!i;
     return undef;
 }
 
@@ -116,7 +116,7 @@ Returns the URI for a local L<RT::Asset> object
 sub URIForObject {
     my $self = shift;
     my $obj  = shift;
-    return $self->LocalURIPrefix . $obj->Id;
+    return $self->LocalURIPrefix . '/' . $obj->Id;
 }
 
 =head2 ParseURI URI

-----------------------------------------------------------------------


More information about the rt-commit mailing list