User: sits    
  Date: 06/05/25 22:42:49

  Modified:    lib      Codestriker.pm
               lib/Codestriker/Action ListTopicsRSS.pm SubmitNewTopic.pm
               lib/Codestriker/Http Input.pm
               lib/Codestriker/Model Comment.pm Delta.pm Topic.pm
  Log:
  Moved the decoding of UTF8 strings closer to the source where they are
  created.  For HTTP parameters, this is set in Input.pm, and for
  database values, this is done in the Model modules.  The Action
  modules don't have to worry about what encoding the string values are in.
  
  
  
  Index: Codestriker.pm
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker.pm,v
  retrieving revision 1.85
  retrieving revision 1.86
  diff -u -r1.85 -r1.86
  --- Codestriker.pm    19 May 2006 00:40:15 -0000      1.85
  +++ Codestriker.pm    26 May 2006 05:42:48 -0000      1.86
  @@ -28,7 +28,7 @@
              );
   
   # Version of Codestriker.
  -$Codestriker::VERSION = "1.9.2-alpha-6";
  +$Codestriker::VERSION = "1.9.2-unicode-unstable";
   
   # Default title to display on each Codestriker screen.
   $Codestriker::title = "Codestriker $Codestriker::VERSION";
  @@ -473,9 +473,18 @@
   
   # Return true if project support has been enabled.
   sub projects_disabled {
  -    return ((defined $Codestriker::allow_projects &&
  -          $Codestriker::allow_projects == 0) ||
  -         $#Codestriker::project_states == -1);
  +    if (defined $Codestriker::project_states) {
  +     return $#Codestriker::project_states == -1;
  +    } elsif (defined $Codestriker::allow_projects) {
  +     # Support for older codestriker.conf files.
  +     if ($Codestriker::allow_projects) {
  +         $Codestriker::project_states = ('Open');
  +     }
  +     return $Codestriker::allow_projects == 0;
  +    } else {
  +     # Don't support projects if none of the above are defined.
  +     return 1;
  +    }
   }
   
   # Return true if there is more than one state associated with a project.
  
  
  
  
  
  Index: ListTopicsRSS.pm
  ===================================================================
  RCS file: 
/cvsroot/codestriker/codestriker/lib/Codestriker/Action/ListTopicsRSS.pm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ListTopicsRSS.pm  22 May 2006 23:19:05 -0000      1.3
  +++ ListTopicsRSS.pm  26 May 2006 05:42:48 -0000      1.4
  @@ -83,8 +83,8 @@
   
        my $comment_link = $url_builder->view_comments_url($topic->{topicid});
   
  -     my $description = decode_utf8($topic->{description});
  -     my $title = decode_utf8($topic->{title});
  +     my $description = $topic->{description};
  +     my $title = $topic->{title};
   
           # Change to 1 to send out the list of files changes in the RSS 
description.
           if (0) {
  @@ -110,7 +110,7 @@
               description=>$description,
               author=> Codestriker->filter_email($topic->{author}),
               
pubDate=>Codestriker->format_short_timestamp($topic->{creation_ts}),
  -            category=>decode_utf8($topic->{project_name}),
  +            category=>$topic->{project_name},
               comments=>$comment_link
               );
   
  
  
  
  
  
  Index: SubmitNewTopic.pm
  ===================================================================
  RCS file: 
/cvsroot/codestriker/codestriker/lib/Codestriker/Action/SubmitNewTopic.pm,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- SubmitNewTopic.pm 22 May 2006 23:19:05 -0000      1.26
  +++ SubmitNewTopic.pm 26 May 2006 05:42:48 -0000      1.27
  @@ -10,7 +10,6 @@
   package Codestriker::Action::SubmitNewTopic;
   
   use strict;
  -use Encode;
   
   use File::Temp qw/ tempfile /;
   use FileHandle;
  @@ -187,8 +186,8 @@
            $temp_topic_fh = tempfile();
            $temp_error_fh = tempfile();
        }
  -#    binmode $temp_topic_fh, ':utf8';
  -#    binmode $temp_error_fh, ':utf8';
  +     binmode $temp_topic_fh, ':utf8';
  +     binmode $temp_error_fh, ':utf8';
        
        my $rc = $repository->getDiff($start_tag, $end_tag, $module,
                                      $temp_topic_fh, $temp_error_fh,
  @@ -219,6 +218,7 @@
       my @deltas = ();
       if ($feedback eq "") {
        # Try to parse the topic text into its diff chunks.
  +     binmode $fh, ':utf8';
        @deltas =
            Codestriker::FileParser::Parser->parse($fh, "text/plain", 
$repository,
                                                   $topicid, $topic_file);
  
  
  
  
  
  Index: Input.pm
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Input.pm,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- Input.pm  5 May 2005 09:35:27 -0000       1.42
  +++ Input.pm  26 May 2006 05:42:49 -0000      1.43
  @@ -10,6 +10,7 @@
   package Codestriker::Http::Input;
   
   use strict;
  +use Encode qw(decode_utf8);
   
   use CGI::Carp 'fatalsToBrowser';
   
  @@ -55,19 +56,19 @@
       $self->{fn} = $query->param('fn');
       $self->{context} = $query->param('context');
       $self->{action} = $query->param('action');
  -    $self->{comments} = $query->param('comments');
  +    $self->{comments} = decode_utf8($query->param('comments'));
       $self->{email} = $query->param('email');
       $self->{author} = $query->param('author');
  -    $self->{topic_text} = $query->param('topic_text');
  -    $self->{topic_title} = $query->param('topic_title');
  -    $self->{topic_description} = $query->param('topic_description');
  +    $self->{topic_text} = decode_utf8($query->param('topic_text'));
  +    $self->{topic_title} = decode_utf8($query->param('topic_title'));
  +    $self->{topic_description} = 
decode_utf8($query->param('topic_description'));
       $self->{reviewers} = $query->param('reviewers');
       $self->{cc} = $query->param('cc');
       $self->{comment_cc} = $query->param('comment_cc');
  -    $self->{topic_state} = $query->param('topic_state');
  -    $self->{comment_state} = $query->param('comment_state');
  +    $self->{topic_state} = decode_utf8($query->param('topic_state'));
  +    $self->{comment_state} = decode_utf8($query->param('comment_state'));
       $self->{revision} = $query->param('revision');
  -    $self->{filename} = $query->param('filename');
  +    $self->{filename} = decode_utf8($query->param('filename'));
       $self->{linenumber} = $query->param('linenumber');
       $self->{mode} = $query->param('mode');
       $self->{brmode} = $query->param('brmode');  
  @@ -79,28 +80,28 @@
       $self->{sreviewer} = $query->param('sreviewer');
       $self->{scc} = $query->param('scc');
       $self->{sbugid} = $query->param('sbugid');
  -    $self->{stext} = $query->param('stext');
  -    $self->{stitle} = $query->param('stitle');
  -    $self->{sdescription} = $query->param('sdescription');
  -    $self->{scomments} = $query->param('scomments');
  -    $self->{sbody} = $query->param('sbody');
  -    $self->{sfilename} = $query->param('sfilename');
  -    $self->{sstate} = $query->param('sstate');
  -    $self->{sproject} = $query->param('sproject');
  +    $self->{stext} = decode_utf8($query->param('stext'));
  +    $self->{stitle} = decode_utf8($query->param('stitle'));
  +    $self->{sdescription} = decode_utf8($query->param('sdescription'));
  +    $self->{scomments} = decode_utf8($query->param('scomments'));
  +    $self->{sbody} = decode_utf8($query->param('sbody'));
  +    $self->{sfilename} = decode_utf8($query->param('sfilename'));
  +    $self->{sstate} = decode_utf8($query->param('sstate'));
  +    $self->{sproject} = decode_utf8($query->param('sproject'));
       $self->{scontext} = $query->param('scontext');
       $self->{version} = $query->param('version');
       $self->{redirect} = $query->param('redirect');
       $self->{a} = $query->param('a');
  -    $self->{updated} = $query->param('updated');
  -    $self->{repository} = $query->param('repository');
  +    $self->{updated} = decode_utf8($query->param('updated'));
  +    $self->{repository} = decode_utf8($query->param('repository'));
       $self->{parallel} = $query->param('parallel');
       $self->{projectid} = $query->param('projectid');
  -    $self->{project_name} = $query->param('project_name');
  -    $self->{project_description} = $query->param('project_description');
  -    $self->{project_state} = $query->param('project_state');
  -    $self->{start_tag} = $query->param('start_tag');
  -    $self->{end_tag} = $query->param('end_tag');
  -    $self->{module} = $query->param('module');
  +    $self->{project_name} = decode_utf8($query->param('project_name'));
  +    $self->{project_description} = 
decode_utf8($query->param('project_description'));
  +    $self->{project_state} = decode_utf8($query->param('project_state'));
  +    $self->{start_tag} = decode_utf8($query->param('start_tag'));
  +    $self->{end_tag} = decode_utf8($query->param('end_tag'));
  +    $self->{module} = decode_utf8($query->param('module'));
       $self->{topic_sort_change} = $query->param('topic_sort_change');
       $self->{format} = $query->param('format');
       $self->{obsoletes} = $query->param('obsoletes');
  
  
  
  
  
  Index: Comment.pm
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Model/Comment.pm,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Comment.pm        22 May 2006 23:19:05 -0000      1.21
  +++ Comment.pm        26 May 2006 05:42:49 -0000      1.22
  @@ -131,7 +131,7 @@
       $self->{filenumber} = $filenumber;
       $self->{filenew} = $filenew;
       $self->{author} = $author;
  -    $self->{data} = decode_utf8($data);
  +    $self->{data} = $data;
       $self->{date} = $timestamp;
       $self->{version} = $version;
       $self->{db_creation_ts} = $creation_ts;
  @@ -308,7 +308,7 @@
            $comment->{filenumber} = $data[3];
            $comment->{filenew} = $data[4];
            $comment->{date} = Codestriker->format_timestamp($data[5]);
  -         $comment->{filename} = $data[6];
  +         $comment->{filename} = decode_utf8($data[6]);
            $comment->{version} = $data[7];
            $comment->{id} = $data[8];
            $comment->{db_creation_ts} = $data[9];
  
  
  
  
  
  Index: Delta.pm
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Model/Delta.pm,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Delta.pm  18 Apr 2006 10:45:43 -0000      1.9
  +++ Delta.pm  26 May 2006 05:42:49 -0000      1.10
  @@ -10,6 +10,7 @@
   package Codestriker::Model::Delta;
   
   use strict;
  +use Encode qw(decode_utf8);
   
   # Create the appropriate delta rows for this review. This gets called
   # by File::get_deltas. It passes in the result of a sql query on the
  @@ -19,13 +20,13 @@
       my $self = {};
       bless $self;
       
  -    $self->{filename} = $_[1];
  +    $self->{filename} = decode_utf8($_[1]);
       $self->{revision} = $_[2];
       $self->{binary} = $_[3];
       $self->{old_linenumber} = $_[4];
       $self->{new_linenumber} = $_[5];
       $self->{text} = $_[6];
  -    $self->{description} = (defined $_[7]) ? $_[7] : "";
  +    $self->{description} = (defined $_[7]) ? decode_utf8($_[7]) : "";
       $self->{filenumber} = $_[8];
       $self->{repmatch} = $_[9];
       $self->{only_delta_in_file} = 0;
  
  
  
  
  
  Index: Topic.pm
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Model/Topic.pm,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- Topic.pm  22 May 2006 23:19:05 -0000      1.44
  +++ Topic.pm  26 May 2006 05:42:49 -0000      1.45
  @@ -203,11 +203,6 @@
       
       Codestriker::DB::DBI->release_connection($dbh, $success);
   
  -    # Mark the user fields as UTF8.
  -    $self->{title} = decode_utf8($title);
  -    $self->{description} = decode_utf8($description);
  -    $self->{document} = decode_utf8($document);
  -
       die $dbh->errstr unless $success;
   }
   
  
  
  


_______________________________________________
Codestriker-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/codestriker-commits

Reply via email to