User: sits    
  Date: 06/06/06 17:35:03

  Modified:    html     codestriker.js
               lib      Codestriker.pm
               lib/Codestriker/Action SubmitNewTopic.pm
               lib/Codestriker/FileParser Parser.pm
               lib/Codestriker/Repository ClearCaseSnapshot.pm Cvs.pm
                        CvsWeb.pm Perforce.pm Subversion.pm ViewCvs.pm
                        Vss.pm
  Log:
  More i18n fixes.  Can now properly view entire files (via the Parallel
  link) in the correct encoding.  Also fixed issues on some platforms,
  where the XmlHttpRequest wasn't working correctly with unicode characters.
  
  
  
  Index: codestriker.js
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/html/codestriker.js,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- codestriker.js    5 Oct 2005 07:56:09 -0000       1.14
  +++ codestriker.js    7 Jun 2006 00:35:01 -0000       1.15
  @@ -23,22 +23,6 @@
       windowHandle.focus();
   }
   
  -// Function for escaping value to be URL safe.  Also
  -// make sure that potentially damaging punctuation
  -// is escaped.  For example, a '+' character will be
  -// interpreted as a space character when it is put into a URL.
  -function extra_escape(value)
  -{
  -    value = escape(value);
  -    value = value.replace(/\//g, "%2F");
  -    value = value.replace(/\?/g, "%3F");
  -    value = value.replace(/\=/g, "%3D");
  -    value = value.replace(/\+/g, "%2B");
  -    value = value.replace(/\&/g, "%26");
  -    value = value.replace(/\@/g, "%40");
  -    return value;
  -}
  -
   // Retrieve the value of a cookie by name.
   function getCookie(name)
   {
  @@ -265,7 +249,7 @@
       // cookie, so that it is remembered for the next add comment tooltip.
       var cookie = getCookie('codestriker_cookie');
       cs_email = comment_form.email.value;
  -    var email_value = extra_escape(cs_email);
  +    var email_value = encodeURIComponent(cs_email);
       if (cookie == null || cookie == '') {
           cookie = 'email&' + email_value;
       }
  @@ -282,20 +266,20 @@
       // request as an XMLHttpRequest, and return false so the browser
       // does nothing else.
       var params = 'action=submit_comment';
  -    params += '&line=' + extra_escape(comment_form.line.value);
  -    params += '&topic=' + extra_escape(comment_form.topic.value);
  -    params += '&fn=' + extra_escape(comment_form.fn.value);
  -    params += '&new=' + extra_escape(comment_form.newval.value);
  -    params += '&comments=' + extra_escape(comment_form.comments.value);
  -    params += '&email=' + extra_escape(comment_form.email.value);
  -    params += '&comment_cc=' + extra_escape(comment_form.comment_cc.value);
  +    params += '&line=' + encodeURIComponent(comment_form.line.value);
  +    params += '&topic=' + encodeURIComponent(comment_form.topic.value);
  +    params += '&fn=' + encodeURIComponent(comment_form.fn.value);
  +    params += '&new=' + encodeURIComponent(comment_form.newval.value);
  +    params += '&comments=' + encodeURIComponent(comment_form.comments.value);
  +    params += '&email=' + encodeURIComponent(comment_form.email.value);
  +    params += '&comment_cc=' + 
encodeURIComponent(comment_form.comment_cc.value);
       params += '&format=xml';
       
       for (var i = 0; i < top.cs_metric_data.length; i++) {
           var comment_param =
  -            extra_escape('comment_state_metric_' + 
top.cs_metric_data[i].name);
  +            encodeURIComponent('comment_state_metric_' + 
top.cs_metric_data[i].name);
           params += '&' + comment_param + '=' +
  -                  extra_escape(eval('comment_form.' + comment_param + 
'.value'));
  +                  encodeURIComponent(eval('comment_form.' + comment_param + 
'.value'));
       }
   
       setStatusText('Submitting comment...');
  
  
  
  
  
  Index: Codestriker.pm
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker.pm,v
  retrieving revision 1.89
  retrieving revision 1.90
  diff -u -r1.89 -r1.90
  --- Codestriker.pm    30 May 2006 07:18:09 -0000      1.89
  +++ Codestriker.pm    7 Jun 2006 00:35:01 -0000       1.90
  @@ -10,6 +10,7 @@
   package Codestriker;
   
   use strict;
  +use Encode;
   
   use Time::Local;
   
  @@ -28,7 +29,7 @@
              );
   
   # Version of Codestriker.
  -$Codestriker::VERSION = "1.9.2-alpha-7";
  +$Codestriker::VERSION = "1.9.2-alpha-8";
   
   # Default title to display on each Codestriker screen.
   $Codestriker::title = "Codestriker $Codestriker::VERSION";
  @@ -504,5 +505,19 @@
       }
   }
   
  +# Decode the passed in string into UTF8.
  +sub decode_topic_text {
  +    my ($string) = @_;
  +
  +    # Assume input text is set to UTF8 by default, unless
  +    # it has been explicitly over-ridden in the codestriker.conf file.
  +    if ((! defined $Codestriker::topic_text_encoding) ||
  +     $Codestriker::topic_text_encoding eq '') {
  +     $Codestriker::topic_text_encoding = 'utf8';
  +    }
  +
  +    return decode($Codestriker::topic_text_encoding, $string);
  +}
  +
   1;
   
  
  
  
  
  
  Index: SubmitNewTopic.pm
  ===================================================================
  RCS file: 
/cvsroot/codestriker/codestriker/lib/Codestriker/Action/SubmitNewTopic.pm,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- SubmitNewTopic.pm 31 May 2006 05:31:07 -0000      1.29
  +++ SubmitNewTopic.pm 7 Jun 2006 00:35:02 -0000       1.30
  @@ -13,7 +13,6 @@
   
   use File::Temp qw/ tempfile /;
   use FileHandle;
  -use Encode;
   
   use Codestriker::Model::Topic;
   use Codestriker::Http::Render;
  @@ -217,20 +216,12 @@
        $fh = $temp_topic_fh;
       }
   
  -    # Assume the topic text input file is set to UTF8 by default, unless
  -    # it has been explicitly over-ridden in the codestriker.conf file.
  -    my $encoding = 'utf8';
  -    if (defined $Codestriker::topic_text_encoding &&
  -     $Codestriker::topic_text_encoding ne '') {
  -     $encoding = $Codestriker::topic_text_encoding;
  -    }
  -
       my @deltas = ();
       if ($feedback eq "") {
        # Try to parse the topic text into its diff chunks.
        @deltas =
            Codestriker::FileParser::Parser->parse($fh, "text/plain", 
$repository,
  -                                                $topicid, $topic_file, 
$encoding);
  +                                                $topicid, $topic_file);
        if ($#deltas == -1) {
            # Nothing in the file, report an error.
            $feedback .= "Reviewable text in topic is empty.\n";
  @@ -250,7 +241,7 @@
       # If the topic text has been uploaded from a file, read from it now.
       if (defined $fh) {
        while (<$fh>) {
  -         $topic_text .= decode($encoding, $_);
  +         $topic_text .= Codestriker::decode_topic_text($_);
        }
        if ($topic_text eq "") {
            if (defined $temp_error_fh) {
  
  
  
  
  
  Index: Parser.pm
  ===================================================================
  RCS file: 
/cvsroot/codestriker/codestriker/lib/Codestriker/FileParser/Parser.pm,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Parser.pm 30 May 2006 07:18:09 -0000      1.21
  +++ Parser.pm 7 Jun 2006 00:35:02 -0000       1.22
  @@ -17,7 +17,6 @@
   
   use FileHandle;
   use File::Temp qw/ tempfile /;
  -use Encode;
   
   use Codestriker::FileParser::CvsUnidiff;
   use Codestriker::FileParser::SubversionDiff;
  @@ -33,7 +32,7 @@
   # lines, revisions and diffs have been submitted in this review.
   sub parse ($$$$$$) {
       my ($type, $fh, $content_type, $repository, $topicid,
  -     $uploaded_filename, $encoding) = @_;
  +     $uploaded_filename) = @_;
   
       # Diffs found.
       my @diffs = ();
  @@ -59,7 +58,7 @@
   
       binmode $fh;
       while (<$fh>) {
  -     my $line = decode($encoding, $_);
  +     my $line = Codestriker::decode_topic_text($_);
        $line =~ s/\r\n/\n/go;
        print $tmpfh $line;
       }
  
  
  
  
  
  Index: ClearCaseSnapshot.pm
  ===================================================================
  RCS file: 
/cvsroot/codestriker/codestriker/lib/Codestriker/Repository/ClearCaseSnapshot.pm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ClearCaseSnapshot.pm      20 Apr 2006 23:51:34 -0000      1.3
  +++ ClearCaseSnapshot.pm      7 Jun 2006 00:35:02 -0000       1.4
  @@ -62,10 +62,11 @@
               $error_msg = "Error from ClearTool: " . join(" ", @errorlines);
               close ERRORFILE;
           } else {
  -            # Operation was succesful.  Load the file into the given array.
  +            # Operation was successful.  Load the file into the given array.
               open CONTENTFILE, "<$tempfile"
                   || die "ClearTool execution succeeded, but Codestriker 
couldn't read from the output file.";
               for (my $i = 1; <CONTENTFILE>; $i++) {
  +             $_ = Codestriker::decode_topic_text($_);
                   chop;
                   $$content_array_ref[$i] = $_;
               }
  
  
  
  
  
  Index: Cvs.pm
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Repository/Cvs.pm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Cvs.pm    1 Nov 2004 10:43:55 -0000       1.3
  +++ Cvs.pm    7 Jun 2006 00:35:02 -0000       1.4
  @@ -66,6 +66,7 @@
   
       # Read the data.
       for (my $i = 1; <CVS>; $i++) {
  +     $_ = Codestriker::decode_topic_text($_);
        chop;
        $$content_array_ref[$i] = $_;
       }
  
  
  
  
  
  Index: CvsWeb.pm
  ===================================================================
  RCS file: 
/cvsroot/codestriker/codestriker/lib/Codestriker/Repository/CvsWeb.pm,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CvsWeb.pm 10 Mar 2004 08:17:08 -0000      1.5
  +++ CvsWeb.pm 7 Jun 2006 00:35:02 -0000       1.6
  @@ -34,7 +34,7 @@
       my $request = $self->{cvsweb_url} . "/~checkout~" .
        "/${filename}?rev=${revision}&content-type=text/plain";
       my $response = $ua->get($request);
  -    my $content = $response->content;
  +    my $content = Codestriker::decode_topic_text($response->content);
       # Store the content lines.
       my @content_lines = split /\n/, $content;
       for (my $i = 0; $i <= $#content_lines; $i++) {
  
  
  
  
  
  Index: Perforce.pm
  ===================================================================
  RCS file: 
/cvsroot/codestriker/codestriker/lib/Codestriker/Repository/Perforce.pm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Perforce.pm       18 Apr 2006 10:45:43 -0000      1.4
  +++ Perforce.pm       7 Jun 2006 00:35:02 -0000       1.5
  @@ -43,6 +43,7 @@
   
       # Read the data.
       for (my $i = 1; <P4>; $i++) {
  +     $_ = Codestriker::decode_topic_text($_);
        chop;
        $$content_array_ref[$i] = $_;
       }
  
  
  
  
  
  Index: Subversion.pm
  ===================================================================
  RCS file: 
/cvsroot/codestriker/codestriker/lib/Codestriker/Repository/Subversion.pm,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Subversion.pm     22 Jan 2006 22:41:27 -0000      1.12
  +++ Subversion.pm     7 Jun 2006 00:35:02 -0000       1.13
  @@ -66,6 +66,7 @@
   
       # Read the data.
       for (my $i = 1; <$read_stdout_fh>; $i++) {
  +     $_ = Codestriker::decode_topic_text($_);
        chop;
        $$content_array_ref[$i] = $_;
       }
  
  
  
  
  
  Index: ViewCvs.pm
  ===================================================================
  RCS file: 
/cvsroot/codestriker/codestriker/lib/Codestriker/Repository/ViewCvs.pm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ViewCvs.pm        10 Mar 2004 08:17:08 -0000      1.4
  +++ ViewCvs.pm        7 Jun 2006 00:35:02 -0000       1.5
  @@ -34,7 +34,7 @@
       my $request = $self->{viewcvs_url} .
        "/${filename}?rev=${revision}&content-type=text/plain";
       my $response = $ua->get($request);
  -    my $content = $response->content;
  +    my $content = Codestriker::decode_topic_text($response->content);
   
       # Store the content lines.
       my @content_lines = split /\n/, $content;
  
  
  
  
  
  Index: Vss.pm
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Repository/Vss.pm,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- Vss.pm    23 Nov 2004 22:40:46 -0000      1.20
  +++ Vss.pm    7 Jun 2006 00:35:02 -0000       1.21
  @@ -90,6 +90,7 @@
       my $basefilename = $1;
       if (open(VSS, "$tempdir/$basefilename")) {
        for (my $i = 1; <VSS>; $i++) {
  +         $_ = Codestriker::decode_topic_text($_);
            chop;
            $$content_array_ref[$i] = $_;
        }
  
  
  


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

Reply via email to