{"thread":{"id":"5715","subject":"[PATCH] gitweb: Escape long title for link tooltips","startedAt":"2006-09-27T02:38:10Z","lastAt":"2006-10-06T08:54:46Z","messageCount":7,"participants":["Yasushi SHOJI","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"27740","messageId":"873baet4ka.wl@mail2.atmark-techno.com","threadId":"5715","inReplyTo":null,"subject":"[PATCH] gitweb: Escape long title for link tooltips","fromName":"Yasushi SHOJI","fromEmail":"yashi@atmark-techno.com","sentAt":"2006-09-27T02:38:10Z","receivedAt":"2006-09-27T02:38:10Z","isPatch":true,"sender":{"key":"yashi@atmark-techno.com","avatar":"https://gravatar.com/avatar/4817e8703ac4379935834d87453faa9d0c94b9dc19d83fcc54c67875eb133e59?d=mp&s=160"},"body":"This is a simple one liner to fix the bug not escaping title string\nfor link tooltips.\n\nThis is not crucial if the commit message is all in ASCII, however, if\nyou decide to use other encoding, such as UTF-8, tooltips ain't\nreadable any more.\n\nSigned-off-by: Yasushi SHOJI <yashi@atmark-techno.com>\n---\n gitweb/gitweb.perl |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 66be619..67f49df 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -617,7 +617,7 @@ sub format_subject_html {\n \n \tif (length($short) < length($long)) {\n \t\treturn $cgi->a({-href => $href, -class => \"list subject\",\n-\t\t                -title => $long},\n+\t\t                -title => esc_html($long)},\n \t\t       esc_html($short) . $extra);\n \t} else {\n \t\treturn $cgi->a({-href => $href, -class => \"list subject\"},\n-- \n1.4.2.1.g83915\n"},{"id":"27745","messageId":"87zmcmroqf.wl@mail2.atmark-techno.com","threadId":"5715","inReplyTo":"871wpyt3ch.wl@mail2.atmark-techno.com","subject":"[PATCH] gitweb: Decode long title for link tooltips","fromName":"Yasushi SHOJI","fromEmail":"yashi@atmark-techno.com","sentAt":"2006-09-27T03:04:10Z","receivedAt":"2006-09-27T03:04:10Z","isPatch":true,"sender":{"key":"yashi@atmark-techno.com","avatar":"https://gravatar.com/avatar/4817e8703ac4379935834d87453faa9d0c94b9dc19d83fcc54c67875eb133e59?d=mp&s=160"},"body":"This is a simple one liner to decode long title string in perl's\ninternal form to utf-8 for link tooltips.\n\nThis is not crucial if the commit message is all in ASCII, however, if\nyou decide to use other encoding, such as UTF-8, tooltips ain't\nreadable any more.\n\nSigned-off-by: Yasushi SHOJI <yashi@atmark-techno.com>\n---\n gitweb/gitweb.perl |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 66be619..597d29f 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -617,7 +617,7 @@ sub format_subject_html {\n \n \tif (length($short) < length($long)) {\n \t\treturn $cgi->a({-href => $href, -class => \"list subject\",\n-\t\t                -title => $long},\n+\t\t                -title => decode(\"utf8\", $long, Encode::FB_DEFAULT)},\n \t\t       esc_html($short) . $extra);\n \t} else {\n \t\treturn $cgi->a({-href => $href, -class => \"list subject\"},\n-- \n1.4.2.1.g83915\n"},{"id":"27744","messageId":"871wpyt3ch.wl@mail2.atmark-techno.com","threadId":"5715","inReplyTo":"873baet4ka.wl@mail2.atmark-techno.com","subject":"Re: [PATCH] gitweb: Escape long title for link tooltips","fromName":"Yasushi SHOJI","fromEmail":"yashi@atmark-techno.com","sentAt":"2006-09-27T03:06:54Z","receivedAt":"2006-09-27T03:06:54Z","isPatch":true,"sender":{"key":"yashi@atmark-techno.com","avatar":"https://gravatar.com/avatar/4817e8703ac4379935834d87453faa9d0c94b9dc19d83fcc54c67875eb133e59?d=mp&s=160"},"body":"At Wed, 27 Sep 2006 11:38:10 +0900,\nYasushi SHOJI wrote:\n> \n> This is a simple one liner to fix the bug not escaping title string\n> for link tooltips.\n\nPlease void the patch.  I'm sending new one.\n-- \n      yashi\n"},{"id":"28066","messageId":"eforb7$fgd$1@sea.gmane.org","threadId":"5715","inReplyTo":"87zmcmroqf.wl@mail2.atmark-techno.com","subject":"Re: [PATCH] gitweb: Decode long title for link tooltips","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-01T16:45:46Z","receivedAt":"2006-10-01T16:45:46Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Yasushi SHOJI wrote:\n\n> This is a simple one liner to decode long title string in perl's\n> internal form to utf-8 for link tooltips.\n> \n> This is not crucial if the commit message is all in ASCII, however, if\n> you decide to use other encoding, such as UTF-8, tooltips ain't\n> readable any more.\n\nPerhaps it would be better to abstract it away into esc_attr (as escape\nattribute) subroutine, if such situation i.e. output of generated string\ninto some attribute of some element happens in some other place.\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"28089","messageId":"87r6xrvi0g.wl@mail2.atmark-techno.com","threadId":"5715","inReplyTo":"eforb7$fgd$1@sea.gmane.org","subject":"Re: [PATCH] gitweb: Decode long title for link tooltips","fromName":"Yasushi SHOJI","fromEmail":"yashi@atmark-techno.com","sentAt":"2006-10-01T21:33:03Z","receivedAt":"2006-10-01T21:33:03Z","isPatch":true,"sender":{"key":"yashi@atmark-techno.com","avatar":"https://gravatar.com/avatar/4817e8703ac4379935834d87453faa9d0c94b9dc19d83fcc54c67875eb133e59?d=mp&s=160"},"body":"At Sun, 01 Oct 2006 18:45:46 +0200,\nJakub Narebski wrote:\n> \n> Yasushi SHOJI wrote:\n> \n> > This is a simple one liner to decode long title string in perl's\n> > internal form to utf-8 for link tooltips.\n> > \n> > This is not crucial if the commit message is all in ASCII, however, if\n> > you decide to use other encoding, such as UTF-8, tooltips ain't\n> > readable any more.\n> \n> Perhaps it would be better to abstract it away into esc_attr (as escape\n> attribute) subroutine, if such situation i.e. output of generated string\n> into some attribute of some element happens in some other place.\n\nI liked the idea.  there were 7 places already.\n\nI just couldn't get why you picked esc_attr for the name.  is there a\npatch for the func I missed?\n\nanyway, a patch for the abstruction is attached.  rename the func name\nif you don't like it.\n\n# i don't know how to reply to an email and also attaching a patch\n# from git format-patch.  should I just submit the patch in a separate\n# email?\n\nregards,\n-- \n        yashi\n\n\n>From cb5f740afb265e67fabf09cd76141fdda24d6745 Mon Sep 17 00:00:00 2001\nFrom: Yasushi SHOJI <yashi@atmark-techno.com>\nDate: Mon, 2 Oct 2006 06:21:33 +0900\nSubject: [PATCH] gitweb: refactor decode() for utf8 conversion\n\nwe already had a few place using decode() to convert perl internal\nencode to utf8.  added a new thin wrapper to do just that.\n\nSigned-off-by: Yasushi SHOJI <yashi@atmark-techno.com>\n---\n gitweb/gitweb.perl |   20 +++++++++++++-------\n 1 files changed, 13 insertions(+), 7 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 44991b1..87a644e 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -440,6 +440,12 @@ sub validate_refname {\n \treturn $input;\n }\n \n+# very thin wrapper for decode(\"utf8\", $str, Encode::FB_DEFAULT);\n+sub to_utf8 {\n+\tmy $str = shift;\n+\treturn decode(\"utf8\", $str, Encode::FB_DEFAULT);\n+}\n+\n # quote unsafe chars, but keep the slash, even when it's not\n # correct, but quoted slashes look too horrible in bookmarks\n sub esc_param {\n@@ -462,7 +468,7 @@ sub esc_url {\n # replace invalid utf8 character with SUBSTITUTION sequence\n sub esc_html {\n \tmy $str = shift;\n-\t$str = decode(\"utf8\", $str, Encode::FB_DEFAULT);\n+\t$str = to_utf8($str);\n \t$str = escapeHTML($str);\n \t$str =~ s/\\014/^L/g; # escape FORM FEED (FF) character (e.g. in COPYING file)\n \treturn $str;\n@@ -664,7 +670,7 @@ sub format_subject_html {\n \n \tif (length($short) < length($long)) {\n \t\treturn $cgi->a({-href => $href, -class => \"list subject\",\n-\t\t                -title => decode(\"utf8\", $long, Encode::FB_DEFAULT)},\n+\t\t                -title => to_utf8($long)},\n \t\t       esc_html($short) . $extra);\n \t} else {\n \t\treturn $cgi->a({-href => $href, -class => \"list subject\"},\n@@ -841,7 +847,7 @@ sub git_get_projects_list {\n \t\t\t    -e \"$projectroot/$path/$export_ok\")) {\n \t\t\t\tmy $pr = {\n \t\t\t\t\tpath => $path,\n-\t\t\t\t\towner => decode(\"utf8\", $owner, Encode::FB_DEFAULT),\n+\t\t\t\t\towner => to_utf8($owner),\n \t\t\t\t};\n \t\t\t\tpush @list, $pr\n \t\t\t}\n@@ -870,7 +876,7 @@ sub git_get_project_owner {\n \t\t\t$pr = unescape($pr);\n \t\t\t$ow = unescape($ow);\n \t\t\tif ($pr eq $project) {\n-\t\t\t\t$owner = decode(\"utf8\", $ow, Encode::FB_DEFAULT);\n+\t\t\t\t$owner = to_utf8($ow);\n \t\t\t\tlast;\n \t\t\t}\n \t\t}\n@@ -1232,7 +1238,7 @@ sub get_file_owner {\n \t}\n \tmy $owner = $gcos;\n \t$owner =~ s/[,;].*$//;\n-\treturn decode(\"utf8\", $owner, Encode::FB_DEFAULT);\n+\treturn to_utf8($owner);\n }\n \n ## ......................................................................\n@@ -3585,7 +3591,7 @@ XML\n \t\t      \"<![CDATA[\\n\";\n \t\tmy $comment = $co{'comment'};\n \t\tforeach my $line (@$comment) {\n-\t\t\t$line = decode(\"utf8\", $line, Encode::FB_DEFAULT);\n+\t\t\t$line = to_utf8($line);\n \t\t\tprint \"$line<br/>\\n\";\n \t\t}\n \t\tprint \"<br/>\\n\";\n@@ -3594,7 +3600,7 @@ XML\n \t\t\t\tnext;\n \t\t\t}\n \t\t\tmy $file = esc_html(unquote($7));\n-\t\t\t$file = decode(\"utf8\", $file, Encode::FB_DEFAULT);\n+\t\t\t$file = to_utf8($file);\n \t\t\tprint \"$file<br/>\\n\";\n \t\t}\n \t\tprint \"]]>\\n\" .\n-- \n1.4.3.rc1\n"},{"id":"28090","messageId":"200610012349.05391.jnareb@gmail.com","threadId":"5715","inReplyTo":"87r6xrvi0g.wl@mail2.atmark-techno.com","subject":"Re: [PATCH] gitweb: Decode long title for link tooltips","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-01T21:49:04Z","receivedAt":"2006-10-01T21:49:04Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Yasushi SHOJI wrote:\n> At Sun, 01 Oct 2006 18:45:46 +0200,\n> Jakub Narebski wrote:\n> > \n> > Yasushi SHOJI wrote:\n> > \n> > > This is a simple one liner to decode long title string in perl's\n> > > internal form to utf-8 for link tooltips.\n> > > \n> > > This is not crucial if the commit message is all in ASCII, however, if\n> > > you decide to use other encoding, such as UTF-8, tooltips ain't\n> > > readable any more.\n> > \n> > Perhaps it would be better to abstract it away into esc_attr (as escape\n> > attribute) subroutine, if such situation i.e. output of generated string\n> > into some attribute of some element happens in some other place.\n> \n> I liked the idea.  there were 7 places already.\n> \n> I just couldn't get why you picked esc_attr for the name.  is there a\n> patch for the func I missed?\n\nTo keep it in the style of names like esc_param (escaping the GET parameter\nto be passed), esc_url (escaping URL to be put as argument of href attribute\nof <link> or <a> element) and esc_html (escaping output). \n\nesc_attr is to escape ATTRibutes of elements, for example title attribute.\nI'm not sure if CGI module does escaping for example of '\"' in attributes...\n\n> anyway, a patch for the abstruction is attached.  rename the func name\n> if you don't like it.\n\nAnyone can send patch renaming subroutines. to_utf8 is a good name... till\nwe allow non-utf8 encodings. And the name can be used for other places where\nwe do string decoding from Perl internal form to utf-8.\n\n> # i don't know how to reply to an email and also attaching a patch\n> # from git format-patch.  should I just submit the patch in a separate\n> # email?\n\nThere are two formats used (check out Documentation/SubmittingPatches).\n\nFirst used for short replies, or some comments which you don't want to have\nin commit description (commit message) is to put additional text just right\nafter \"---\" separating commit message from the patch.\n\nSecond, used for example if reply is longer than commit message, or patch\nis just an attachement/footnote to reply, is to put the reply above the\nbody of message generated by format patch, and separate it from the\npatch for example by \"-- >8 --\". The idea is that committer can remove the\ntop part of email and apply the rest as is.\n-- \nJakub Narebski\nPoland\n"},{"id":"28276","messageId":"eg55jb$nar$1@sea.gmane.org","threadId":"5715","inReplyTo":"87r6xrvi0g.wl@mail2.atmark-techno.com","subject":"Re: [PATCH] gitweb: Decode long title for link tooltips","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-06T08:54:46Z","receivedAt":"2006-10-06T08:54:46Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Yasushi SHOJI wrote:\n\n[...]]\n> Subject: [PATCH] gitweb: refactor decode() for utf8 conversion\n> \n> we already had a few place using decode() to convert perl internal\n> encode to utf8.  added a new thin wrapper to do just that.\n> \n> Signed-off-by: Yasushi SHOJI <yashi@atmark-techno.com>\n\nWhat happened to this patch? Dropped or omitted by mistake?\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"}]}