Changeset 23463

Show
Ignore:
Timestamp:
13.12.2010 15:24:36 (9 years ago)
Author:
ak19
Message:

Previously, when reverting back to an earlier RE match for replace_href_links, we reverted back too far (back to an earlier one that had a problem with spaces withing an href="...")

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/HTMLPlugin.pm

    r23419 r23463  
    710710        $self->replace_usemap_links($1, $2, $3)/isge; 
    711711 
    712     $$textref =~ s/(<(?:a|area|frame|link|script)\s+[^>]*?\s*(?:href|src)\s*=\s*[\"\']?)([^\"\'>\s]+)([\"\']?[^>]*>)/ 
    713         $self->replace_href_links ($1, $2, $3, $base_dir, $file, $doc_obj, $cursection)/isge; 
     712    $$textref =~ s/(<(?:a|area|frame|link|script)\s+[^>]*?\s*(?:href|src)\s*=\s*)((?:[\"][^\"]+[\"])|(?:[\'][^\']+[\'])|(?:[^\s\/>]+))([^>]*>)/ 
     713        $self->replace_href_links ($1, $2, $3, $base_dir, $file, $doc_obj, $cursection)/isge;  
    714714     
    715715##  $$textref =~ s/($opencom.*?)?+(<(?:a|area|frame|link|script)\s+[^>]*?\s*(?:href|src)\s*=\s*)((?:[\"][^\"]+[\"])|(?:[\'][^\']+[\'])|(?:[^\s\/>]+))([^>]*>)(.*?$closecom)?+/ 
     
    798798    my $self = shift (@_); 
    799799    my ($front, $link, $back, $base_dir, $file, $doc_obj, $section) = @_; 
    800  
     800     
    801801    # remove quotes from link at start and end if necessary 
    802802    if ($link=~/^[\"\']/) { 
     
    10391039    # strip off hash part, e.g. #foo, but watch out for any entities, e.g. &#x3B1; 
    10401040    my ($before_hash, $hash_part) = $link =~ m/^(.*?[^&])(\#.*)?$/; 
    1041      
     1041     
    10421042    $hash_part = "" if !defined $hash_part; 
    10431043    if (!defined $before_hash || $before_hash !~ m/[\w\.\/]/) { 
    1044     my $outhandle = $self->{'outhandle'}; 
    1045     print $outhandle "HTMLPlugin: ERROR - badly formatted tag ignored ($link)\n" 
    1046         if $self->{'verbosity'}; 
    1047     return ($link, "", 0); 
    1048     } 
    1049  
     1044        my $outhandle = $self->{'outhandle'}; 
     1045        print $outhandle "HTMLPlugin: ERROR - badly formatted tag ignored ($link)\n" 
     1046            if $self->{'verbosity'}; 
     1047        return ($link, "", 0); 
     1048    } 
     1049     
    10501050    if ($before_hash =~ s@^((?:http|https|ftp|file|mms)://)@@i) { 
    1051     my $type = $1; 
     1051        my $type = $1; 
    10521052 
    10531053    if ($link =~ m/^(http|ftp):/i) {