Changeset 12141

Show
Ignore:
Timestamp:
05/21/08 22:28:32 (5 years ago)
Author:
hio
Message:

なチャンネルの調整.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/tiarra/trunk/module/System/WebClient.pm

    r11017 r12141  
    1919use BulletinBoard; 
    2020use Module::Use qw(Tools::HTTPServer Tools::HTTPParser Log::Logger Auto::Utils); 
     21use Unicode::Japanese; 
    2122 
    2223use IO::Socket::INET; 
     
    535536 
    536537    $ch_short =~ s/%([0-9a-f]{2})/pack("H*",$1)/gie; 
    537     $ch_short =~ s/^=// or $ch_short = '#'.$ch_short; 
    538     if( !$this->{cache}{$netname}{$ch_short} ) 
    539     { 
    540       use Unicode::Japanese; 
    541       my $ch2 = Unicode::Japanese->new($ch_short,'sjis')->utf8; 
    542       if( $this->{cache}{$netname}{$ch2} ) 
    543       { 
    544         $ch_short = $ch2; 
    545       }else 
    546       { 
    547         RunLoop->shared_loop->notify_msg(__PACKAGE__."#_dispatch($path), not in cache ($netname/$ch_short)"); 
    548         $this->_response($req, 404); 
    549         return; 
    550       } 
    551     } 
     538    my $ch_short_orig = $ch_short; 
     539    $ch_short = $this->_detect_channel($ch_short, $netname); 
     540    if( !$ch_short ) 
     541    { 
     542      RunLoop->shared_loop->notify_msg(__PACKAGE__."#_dispatch($path), not in cache ($netname/$ch_short_orig)"); 
     543      $this->_response($req, 404); 
     544      return; 
     545    } 
     546 
    552547    if( !$this->_can_show($req, $ch_short, $netname) ) 
    553548    { 
     
    584579    $this->_response($req, 404); 
    585580  } 
     581} 
     582 
     583# $this->_detect_channel($ch_short, $netname). 
     584sub _detect_channel 
     585{ 
     586  my $this = shift; 
     587  my $ch_short = shift; 
     588  my $netname  = shift; 
     589 
     590  if( $ch_short =~ s/^=// ) 
     591  { 
     592    # priv or special channels. 
     593    return $ch_short; 
     594  } 
     595 
     596  if( $ch_short =~ s/^!// ) 
     597  { 
     598    foreach my $key (keys %{$this->{cache}{$netname}}) 
     599    { 
     600      $key =~ /^![0-9A-Z]{5}/ or next; 
     601      substr($key, 6) eq $ch_short or next; 
     602      return $key; 
     603    } 
     604    # try decode from sjis. 
     605    my $ch2 = Unicode::Japanese->new($ch_short,'sjis')->utf8; 
     606    foreach my $key (keys %{$this->{cache}{$netname}}) 
     607    { 
     608      $key =~ /^![0-9A-Z]{5}/ or next; 
     609      substr($key, 6) eq $ch2 or next; 
     610      return $key; 
     611    } 
     612    # not found. 
     613    return undef; 
     614  } 
     615 
     616  # normal channels. 
     617  $ch_short = '#'.$ch_short; 
     618  if( $this->{cache}{$netname}{$ch_short} ) 
     619  { 
     620    # found. 
     621    return $ch_short; 
     622  } 
     623 
     624  # try decode from sjis. 
     625  my $ch2 = Unicode::Japanese->new($ch_short,'sjis')->utf8; 
     626  if( $this->{cache}{$netname}{$ch2} ) 
     627  { 
     628    return $ch2; 
     629  } 
     630 
     631  # not found. 
     632  return undef; 
    586633} 
    587634 
     
    771818      { 
    772819        my $link_ch = $channame; 
    773         $link_ch =~ s/^#// or $link_ch = "=$link_ch"; 
     820        if( $link_ch =~ s/^#// ) 
     821        { 
     822          # normal channels. 
     823        }elsif( $link_ch =~ s/^![0-9A-Z]{5}/!/ ) 
     824        { 
     825          # channel    =  ( "#" / "+" / ( "!" channelid ) / "&" ) chanstring [ ":" chanstring ] 
     826          # channelid  = 5( %x41-5A / digit )   ; 5( A-Z / 0-9 ) 
     827          # (RFC2812) 
     828        }else 
     829        { 
     830          $link_ch = "=$link_ch"; 
     831        } 
    774832        my $link = "log\0$netname\0$link_ch\0"; 
    775833        $link =~ s{/}{%2F}g; 
    776834        $link =~ tr{\0}{/}; 
    777835        $link = $this->_escapeHTML($link); 
    778         $content .= qq{<li><a href="$link">$channame</a></li>\n}; 
     836 
     837        my $channame_label = $this->_escapeHTML($channame); 
     838        $channame_label =~ s/^![0-9A-Z]{5}/!/; 
     839        $content .= qq{<li><a href="$link">$channame_label</a></li>\n}; 
    779840      } 
    780841      $content .= "  </ul>\n"; 
     
    10421103 
    10431104  my $ch_long = Multicast::attach($ch_short, $netname); 
     1105  $ch_long =~ s/^![0-9A-Z]{5}/!/; 
    10441106  my $ch_long_esc = $this->_escapeHTML($ch_long); 
    10451107  my $name_esc = $this->_escapeHTML($cgi->{n} || ''); 
     
    12971359 
    12981360  my $ch_long = Multicast::attach($ch_short, $netname); 
     1361  $ch_long =~ s/^![0-9A-Z]{5}/!/; 
    12991362  my $ch_long_esc = $this->_escapeHTML($ch_long); 
    13001363 
     
    13471410 
    13481411<form action="./info" method="post"> 
    1349 JOIN <input type="text" name="join" value="<&CH_LONG>" /> 
     1412JOIN <input type="hidden" name="join" value="<&CH_LONG>" /> 
    13501413<input type="submit" value="入室" /><br /> 
    13511414</form> 
    13521415 
    13531416<form action="./info" method="post"> 
    1354 DELETE <input type="text" name="delete" value="<&CH_LONG>" /> 
     1417DELETE <input type="hidden" name="delete" value="<&CH_LONG>" /> 
    13551418<input type="submit" value="削除" /><br /> 
    13561419</form>