* [PATCH] gitweb: Escape long title for link tooltips @ 2006-09-27 2:38 Yasushi SHOJI 2006-09-27 3:06 ` Yasushi SHOJI 0 siblings, 1 reply; 7+ messages in thread From: Yasushi SHOJI @ 2006-09-27 2:38 UTC (permalink / raw) To: git This is a simple one liner to fix the bug not escaping title string for link tooltips. This is not crucial if the commit message is all in ASCII, however, if you decide to use other encoding, such as UTF-8, tooltips ain't readable any more. Signed-off-by: Yasushi SHOJI <yashi@atmark-techno.com> --- gitweb/gitweb.perl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 66be619..67f49df 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -617,7 +617,7 @@ sub format_subject_html { if (length($short) < length($long)) { return $cgi->a({-href => $href, -class => "list subject", - -title => $long}, + -title => esc_html($long)}, esc_html($short) . $extra); } else { return $cgi->a({-href => $href, -class => "list subject"}, -- 1.4.2.1.g83915 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] gitweb: Escape long title for link tooltips 2006-09-27 2:38 [PATCH] gitweb: Escape long title for link tooltips Yasushi SHOJI @ 2006-09-27 3:06 ` Yasushi SHOJI 2006-09-27 3:04 ` [PATCH] gitweb: Decode " Yasushi SHOJI 0 siblings, 1 reply; 7+ messages in thread From: Yasushi SHOJI @ 2006-09-27 3:06 UTC (permalink / raw) To: git At Wed, 27 Sep 2006 11:38:10 +0900, Yasushi SHOJI wrote: > > This is a simple one liner to fix the bug not escaping title string > for link tooltips. Please void the patch. I'm sending new one. -- yashi ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] gitweb: Decode long title for link tooltips 2006-09-27 3:06 ` Yasushi SHOJI @ 2006-09-27 3:04 ` Yasushi SHOJI 2006-10-01 16:45 ` Jakub Narebski 0 siblings, 1 reply; 7+ messages in thread From: Yasushi SHOJI @ 2006-09-27 3:04 UTC (permalink / raw) To: git This is a simple one liner to decode long title string in perl's internal form to utf-8 for link tooltips. This is not crucial if the commit message is all in ASCII, however, if you decide to use other encoding, such as UTF-8, tooltips ain't readable any more. Signed-off-by: Yasushi SHOJI <yashi@atmark-techno.com> --- gitweb/gitweb.perl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 66be619..597d29f 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -617,7 +617,7 @@ sub format_subject_html { if (length($short) < length($long)) { return $cgi->a({-href => $href, -class => "list subject", - -title => $long}, + -title => decode("utf8", $long, Encode::FB_DEFAULT)}, esc_html($short) . $extra); } else { return $cgi->a({-href => $href, -class => "list subject"}, -- 1.4.2.1.g83915 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] gitweb: Decode long title for link tooltips 2006-09-27 3:04 ` [PATCH] gitweb: Decode " Yasushi SHOJI @ 2006-10-01 16:45 ` Jakub Narebski 2006-10-01 21:33 ` Yasushi SHOJI 0 siblings, 1 reply; 7+ messages in thread From: Jakub Narebski @ 2006-10-01 16:45 UTC (permalink / raw) To: git Yasushi SHOJI wrote: > This is a simple one liner to decode long title string in perl's > internal form to utf-8 for link tooltips. > > This is not crucial if the commit message is all in ASCII, however, if > you decide to use other encoding, such as UTF-8, tooltips ain't > readable any more. Perhaps it would be better to abstract it away into esc_attr (as escape attribute) subroutine, if such situation i.e. output of generated string into some attribute of some element happens in some other place. -- Jakub Narebski Warsaw, Poland ShadeHawk on #git ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] gitweb: Decode long title for link tooltips 2006-10-01 16:45 ` Jakub Narebski @ 2006-10-01 21:33 ` Yasushi SHOJI 2006-10-01 21:49 ` Jakub Narebski 2006-10-06 8:54 ` Jakub Narebski 0 siblings, 2 replies; 7+ messages in thread From: Yasushi SHOJI @ 2006-10-01 21:33 UTC (permalink / raw) To: Jakub Narebski; +Cc: git At Sun, 01 Oct 2006 18:45:46 +0200, Jakub Narebski wrote: > > Yasushi SHOJI wrote: > > > This is a simple one liner to decode long title string in perl's > > internal form to utf-8 for link tooltips. > > > > This is not crucial if the commit message is all in ASCII, however, if > > you decide to use other encoding, such as UTF-8, tooltips ain't > > readable any more. > > Perhaps it would be better to abstract it away into esc_attr (as escape > attribute) subroutine, if such situation i.e. output of generated string > into some attribute of some element happens in some other place. I liked the idea. there were 7 places already. I just couldn't get why you picked esc_attr for the name. is there a patch for the func I missed? anyway, a patch for the abstruction is attached. rename the func name if you don't like it. # i don't know how to reply to an email and also attaching a patch # from git format-patch. should I just submit the patch in a separate # email? regards, -- yashi >From cb5f740afb265e67fabf09cd76141fdda24d6745 Mon Sep 17 00:00:00 2001 From: Yasushi SHOJI <yashi@atmark-techno.com> Date: Mon, 2 Oct 2006 06:21:33 +0900 Subject: [PATCH] gitweb: refactor decode() for utf8 conversion we already had a few place using decode() to convert perl internal encode to utf8. added a new thin wrapper to do just that. Signed-off-by: Yasushi SHOJI <yashi@atmark-techno.com> --- gitweb/gitweb.perl | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 44991b1..87a644e 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -440,6 +440,12 @@ sub validate_refname { return $input; } +# very thin wrapper for decode("utf8", $str, Encode::FB_DEFAULT); +sub to_utf8 { + my $str = shift; + return decode("utf8", $str, Encode::FB_DEFAULT); +} + # quote unsafe chars, but keep the slash, even when it's not # correct, but quoted slashes look too horrible in bookmarks sub esc_param { @@ -462,7 +468,7 @@ sub esc_url { # replace invalid utf8 character with SUBSTITUTION sequence sub esc_html { my $str = shift; - $str = decode("utf8", $str, Encode::FB_DEFAULT); + $str = to_utf8($str); $str = escapeHTML($str); $str =~ s/\014/^L/g; # escape FORM FEED (FF) character (e.g. in COPYING file) return $str; @@ -664,7 +670,7 @@ sub format_subject_html { if (length($short) < length($long)) { return $cgi->a({-href => $href, -class => "list subject", - -title => decode("utf8", $long, Encode::FB_DEFAULT)}, + -title => to_utf8($long)}, esc_html($short) . $extra); } else { return $cgi->a({-href => $href, -class => "list subject"}, @@ -841,7 +847,7 @@ sub git_get_projects_list { -e "$projectroot/$path/$export_ok")) { my $pr = { path => $path, - owner => decode("utf8", $owner, Encode::FB_DEFAULT), + owner => to_utf8($owner), }; push @list, $pr } @@ -870,7 +876,7 @@ sub git_get_project_owner { $pr = unescape($pr); $ow = unescape($ow); if ($pr eq $project) { - $owner = decode("utf8", $ow, Encode::FB_DEFAULT); + $owner = to_utf8($ow); last; } } @@ -1232,7 +1238,7 @@ sub get_file_owner { } my $owner = $gcos; $owner =~ s/[,;].*$//; - return decode("utf8", $owner, Encode::FB_DEFAULT); + return to_utf8($owner); } ## ...................................................................... @@ -3585,7 +3591,7 @@ XML "<![CDATA[\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { - $line = decode("utf8", $line, Encode::FB_DEFAULT); + $line = to_utf8($line); print "$line<br/>\n"; } print "<br/>\n"; @@ -3594,7 +3600,7 @@ XML next; } my $file = esc_html(unquote($7)); - $file = decode("utf8", $file, Encode::FB_DEFAULT); + $file = to_utf8($file); print "$file<br/>\n"; } print "]]>\n" . -- 1.4.3.rc1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] gitweb: Decode long title for link tooltips 2006-10-01 21:33 ` Yasushi SHOJI @ 2006-10-01 21:49 ` Jakub Narebski 2006-10-06 8:54 ` Jakub Narebski 1 sibling, 0 replies; 7+ messages in thread From: Jakub Narebski @ 2006-10-01 21:49 UTC (permalink / raw) To: Yasushi SHOJI; +Cc: git Yasushi SHOJI wrote: > At Sun, 01 Oct 2006 18:45:46 +0200, > Jakub Narebski wrote: > > > > Yasushi SHOJI wrote: > > > > > This is a simple one liner to decode long title string in perl's > > > internal form to utf-8 for link tooltips. > > > > > > This is not crucial if the commit message is all in ASCII, however, if > > > you decide to use other encoding, such as UTF-8, tooltips ain't > > > readable any more. > > > > Perhaps it would be better to abstract it away into esc_attr (as escape > > attribute) subroutine, if such situation i.e. output of generated string > > into some attribute of some element happens in some other place. > > I liked the idea. there were 7 places already. > > I just couldn't get why you picked esc_attr for the name. is there a > patch for the func I missed? To keep it in the style of names like esc_param (escaping the GET parameter to be passed), esc_url (escaping URL to be put as argument of href attribute of <link> or <a> element) and esc_html (escaping output). esc_attr is to escape ATTRibutes of elements, for example title attribute. I'm not sure if CGI module does escaping for example of '"' in attributes... > anyway, a patch for the abstruction is attached. rename the func name > if you don't like it. Anyone can send patch renaming subroutines. to_utf8 is a good name... till we allow non-utf8 encodings. And the name can be used for other places where we do string decoding from Perl internal form to utf-8. > # i don't know how to reply to an email and also attaching a patch > # from git format-patch. should I just submit the patch in a separate > # email? There are two formats used (check out Documentation/SubmittingPatches). First used for short replies, or some comments which you don't want to have in commit description (commit message) is to put additional text just right after "---" separating commit message from the patch. Second, used for example if reply is longer than commit message, or patch is just an attachement/footnote to reply, is to put the reply above the body of message generated by format patch, and separate it from the patch for example by "-- >8 --". The idea is that committer can remove the top part of email and apply the rest as is. -- Jakub Narebski Poland ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] gitweb: Decode long title for link tooltips 2006-10-01 21:33 ` Yasushi SHOJI 2006-10-01 21:49 ` Jakub Narebski @ 2006-10-06 8:54 ` Jakub Narebski 1 sibling, 0 replies; 7+ messages in thread From: Jakub Narebski @ 2006-10-06 8:54 UTC (permalink / raw) To: git Yasushi SHOJI wrote: [...]] > Subject: [PATCH] gitweb: refactor decode() for utf8 conversion > > we already had a few place using decode() to convert perl internal > encode to utf8. added a new thin wrapper to do just that. > > Signed-off-by: Yasushi SHOJI <yashi@atmark-techno.com> What happened to this patch? Dropped or omitted by mistake? -- Jakub Narebski Warsaw, Poland ShadeHawk on #git ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-10-06 8:58 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2006-09-27 2:38 [PATCH] gitweb: Escape long title for link tooltips Yasushi SHOJI 2006-09-27 3:06 ` Yasushi SHOJI 2006-09-27 3:04 ` [PATCH] gitweb: Decode " Yasushi SHOJI 2006-10-01 16:45 ` Jakub Narebski 2006-10-01 21:33 ` Yasushi SHOJI 2006-10-01 21:49 ` Jakub Narebski 2006-10-06 8:54 ` Jakub Narebski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).