From: Metabox Date: Sat, 27 Apr 2019 19:40:49 +0000 (+1000) Subject: New LNK LTag and fix for img href bug. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=6c1573f9d2e7d9c3e5435c6ae8f5202bf4eeb7bf;p=LifeLog.git New LNK LTag and fix for img href bug. --- diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index 9f63156..2dddb15 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -235,19 +235,31 @@ while(my @row = $st->fetchrow_array()) { $tfId = 1; } + my $sub =""; + #Check for LNK takes precedence here as we also parse plain placed URL's for http protocol later. + if($log =~ /<', $idx); + $sub = substr($log, $idx+1,$len-$idx-1); + my $url = qq($sub); + $tags .= qq(\n); + $log=~s/</$url/osi; + } + + if($log =~ /<', $idx); - my $sub = substr($log,$idx+1,$len-$idx-1); - my $url = qq("); + $sub = substr($log,$idx+1,$len-$idx-1); + my $url = qq(); $tags .= qq(\n); $log=~s/</$url/osi; } elsif($log =~ /<', $idx); - my $sub = substr($log, $idx+1,$len-$idx-1); + $sub = substr($log, $idx+1,$len-$idx-1); my $lnk = $sub; if($lnk =~ /_frm.png/) { my $ext = substr($lnk, index($lnk,'.')); @@ -260,20 +272,21 @@ while(my @row = $st->fetchrow_array()) { } $lnk = qq(\n ); - }else{ + }else{ #TODO fetch from web locally the original image. $lnk = qq(\n); - } - $tags .= qq(\n); + } + $tags .= qq(\n); $log=~s/</$lnk/o; } #Replace with a full link an HTTP URI my @chnks = split(/($re_a_tag)/si , $log) ; - foreach my $ch_i ( @chnks ) { - next if $ch_i =~ /$re_a_tag/ ; - $ch_i =~ s/https/http/gsi; - $ch_i =~ s/($RE{URI}{HTTP})/$1<\/a>/gsi; + foreach my $ch_i ( @chnks ) { + next if $ch_i =~ /$re_a_tag/; + next if index($ch_i, "-1; + $ch_i =~ s/https/http/gsi; + $ch_i =~ s/($RE{URI}{HTTP})/$1<\/a>/gsi; } $log = join('' , @chnks);