{"thread":{"id":"25163","subject":"Re: [PATCH] Enable highlight executable path as a configuration option","startedAt":"2010-09-20T09:10:37Z","lastAt":"2010-09-21T19:09:40Z","messageCount":3,"participants":["Jakub Narebski","Christopher Wilson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"151095","messageId":"201009201110.38271.jnareb@gmail.com","threadId":"25163","inReplyTo":"4C96938C.5050505@cdwilson.us","subject":"Re: [PATCH] Enable highlight executable path as a configuration option","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-09-20T09:10:37Z","receivedAt":"2010-09-20T09:10:37Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Mon, 20 Sep 2010, Christopher Wilson wrote:\n\n> Allow build-time/run-time configuration of the highlight executable. Defaults\n> to previous behavior which assumes that highlight is available on the server\n> PATH. However, if this is not the case, the path to the highlight executable\n> can be configured at build time as a configuration variable\n> \n>     HIGHLIGHT_BIN = /path/to/highlight\n> \n> or at runtime by configuring GITWEB_CONFIG\n> \n>     $highlight_bin = /path/to/highlight\n> \n> Signed-off-by: Christopher Wilson <cwilson@cdwilson.us>\n\nGood idea... but I am not sure about shell quoting and the problem\nwith spaces in pathnames.  See comments below.\n\n> ---\n>  gitweb/Makefile    |    4 +++-\n>  gitweb/README      |    7 ++++++-\n>  gitweb/gitweb.perl |    6 +++++-\n>  3 files changed, 14 insertions(+), 3 deletions(-)\n\n> diff --git a/gitweb/README b/gitweb/README\n> index d481198..69f9860 100644\n> --- a/gitweb/README\n> +++ b/gitweb/README\n> @@ -114,6 +114,9 @@ You can specify the following configuration variables when building GIT:\n>     when gitweb.cgi is executed, then the file specified in the environment\n>     variable will be loaded instead of the file specified when gitweb.cgi was\n>     created.  [Default: /etc/gitweb.conf]\n> + * HIGHLIGHT_BIN\n> +   Path to the highlight executable to use. Useful if highlight is not\n> +   installed on your webserver's PATH. [Default: highlight]\n  \nI think it needs to be said that this 'highlight' executable must be \nthe one from http://www.andre-simon.de (assumptions about parameters and\noutput).\n  \n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index a85e2f6..e808485 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n[...]\n> @@ -3360,7 +3364,7 @@ sub run_highlighter {\n>  \tclose $fd\n>  \t\tor die_error(404, \"Reading blob failed\");\n>  \topen $fd, quote_command(git_cmd(), \"cat-file\", \"blob\", $hash).\" | \".\n> -\t          \"highlight --xhtml --fragment --syntax $syntax |\"\n> +\t          \"$highlight_bin --xhtml --fragment --syntax $syntax |\"\n\nI think you need \n\n  +\t          quote_command($highlight_bin).\" --xhtml --fragment --syntax $syntax |\"\n\nhere\n\n>  \t\tor die_error(500, \"Couldn't open file or run syntax highlighter\");\n>  \treturn $fd;\n>  }\n> -- \n> 1.7.2.3\n> \n> \n\n-- \nJakub Narebski\nPoland\n"},{"id":"151187","messageId":"4C985DDF.8060807@cdwilson.us","threadId":"25163","inReplyTo":"201009201110.38271.jnareb@gmail.com","subject":"Re: [PATCH] Enable highlight executable path as a configuration option","fromName":"Christopher Wilson","fromEmail":"cwilson@cdwilson.us","sentAt":"2010-09-21T07:25:19Z","receivedAt":"2010-09-21T07:25:19Z","isPatch":true,"sender":{"key":"cwilson@cdwilson.us","avatar":"https://avatars.githubusercontent.com/u/14631?v=4"},"body":"On 9/20/10 2:10 AM, Jakub Narebski wrote:\n> On Mon, 20 Sep 2010, Christopher Wilson wrote:\n> \n>> Allow build-time/run-time configuration of the highlight executable. Defaults\n>> to previous behavior which assumes that highlight is available on the server\n>> PATH. However, if this is not the case, the path to the highlight executable\n>> can be configured at build time as a configuration variable\n>>\n>>      HIGHLIGHT_BIN = /path/to/highlight\n>>\n>> or at runtime by configuring GITWEB_CONFIG\n>>\n>>      $highlight_bin = /path/to/highlight\n>>\n>> Signed-off-by: Christopher Wilson<cwilson@cdwilson.us>\n> \n> Good idea... but I am not sure about shell quoting and the problem\n> with spaces in pathnames.  See comments below.\n> \n>> ---\n>>   gitweb/Makefile    |    4 +++-\n>>   gitweb/README      |    7 ++++++-\n>>   gitweb/gitweb.perl |    6 +++++-\n>>   3 files changed, 14 insertions(+), 3 deletions(-)\n> \n>> diff --git a/gitweb/README b/gitweb/README\n>> index d481198..69f9860 100644\n>> --- a/gitweb/README\n>> +++ b/gitweb/README\n>> @@ -114,6 +114,9 @@ You can specify the following configuration variables when building GIT:\n>>      when gitweb.cgi is executed, then the file specified in the environment\n>>      variable will be loaded instead of the file specified when gitweb.cgi was\n>>      created.  [Default: /etc/gitweb.conf]\n>> + * HIGHLIGHT_BIN\n>> +   Path to the highlight executable to use. Useful if highlight is not\n>> +   installed on your webserver's PATH. [Default: highlight]\n> \n> I think it needs to be said that this 'highlight' executable must be\n> the one from http://www.andre-simon.de (assumptions about parameters and\n> output).\n> \n>> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n>> index a85e2f6..e808485 100755\n>> --- a/gitweb/gitweb.perl\n>> +++ b/gitweb/gitweb.perl\n> [...]\n>> @@ -3360,7 +3364,7 @@ sub run_highlighter {\n>>   \tclose $fd\n>>   \t\tor die_error(404, \"Reading blob failed\");\n>>   \topen $fd, quote_command(git_cmd(), \"cat-file\", \"blob\", $hash).\" | \".\n>> -\t          \"highlight --xhtml --fragment --syntax $syntax |\"\n>> +\t          \"$highlight_bin --xhtml --fragment --syntax $syntax |\"\n> \n> I think you need\n> \n>    +\t          quote_command($highlight_bin).\" --xhtml --fragment --syntax $syntax |\"\n> \n> here\n> \n>>   \t\tor die_error(500, \"Couldn't open file or run syntax highlighter\");\n>>   \treturn $fd;\n>>   }\n>> -- \n>> 1.7.2.3\n>>\n>>\n> \n\nJakub, thanks for the helpful feedback.  I included the updated patch (see below) which includes the changes you suggested.\n\nAllow build-time/run-time configuration of the highlight executable\n(must be the one from http://www.andre-simon.de due to assumptions\nabout parameters and output).  Defaults to previous behavior which\nassumes that highlight is available on the server PATH. However, if\nthis is not the case, the path to the highlight executable can be\nconfigured at build time as a configuration variable\n\n    HIGHLIGHT_BIN = /path/to/highlight\n\nor at runtime by configuring GITWEB_CONFIG\n\n    $highlight_bin = /path/to/highlight\n\nSigned-off-by: Christopher Wilson <cwilson@cdwilson.us>\n---\n gitweb/Makefile    |    4 +++-\n gitweb/README      |   11 ++++++++++-\n gitweb/gitweb.perl |    9 ++++++++-\n 3 files changed, 21 insertions(+), 3 deletions(-)\n mode change 100644 => 100755 gitweb/README\n\ndiff --git a/gitweb/Makefile b/gitweb/Makefile\nindex 2fb7c2d..e32ee76 100644\n--- a/gitweb/Makefile\n+++ b/gitweb/Makefile\n@@ -35,6 +35,7 @@ GITWEB_FAVICON = static/git-favicon.png\n GITWEB_JS = static/gitweb.js\n GITWEB_SITE_HEADER =\n GITWEB_SITE_FOOTER =\n+HIGHLIGHT_BIN = highlight\n \n # include user config\n -include ../config.mak.autogen\n@@ -129,7 +130,8 @@ GITWEB_REPLACE = \\\n \t-e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \\\n \t-e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \\\n \t-e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \\\n-\t-e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g'\n+\t-e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \\\n+\t-e 's|++HIGHLIGHT_BIN++|$(HIGHLIGHT_BIN)|g'\n \n GITWEB-BUILD-OPTIONS: FORCE\n \t@rm -f $@+\ndiff --git a/gitweb/README b/gitweb/README\nold mode 100644\nnew mode 100755\nindex d481198..bf3664f\n--- a/gitweb/README\n+++ b/gitweb/README\n@@ -114,6 +114,11 @@ You can specify the following configuration variables when building GIT:\n    when gitweb.cgi is executed, then the file specified in the environment\n    variable will be loaded instead of the file specified when gitweb.cgi was\n    created.  [Default: /etc/gitweb.conf]\n+ * HIGHLIGHT_BIN\n+   Path to the highlight executable to use (must be the one from\n+   http://www.andre-simon.de due to assumptions about parameters and output).\n+   Useful if highlight is not installed on your webserver's PATH.\n+   [Default: highlight]\n \n \n Runtime gitweb configuration\n@@ -236,7 +241,11 @@ not include variables usually directly set during build):\n    If server load exceed this value then return \"503 Service Unavailable\" error.\n    Server load is taken to be 0 if gitweb cannot determine its value.  Set it to\n    undefined value to turn it off.  The default is 300.\n-\n+ * $highlight_bin\n+   Path to the highlight executable to use (must be the one from\n+   http://www.andre-simon.de due to assumptions about parameters and output).\n+   Useful if highlight is not installed on your webserver's PATH.\n+   [Default: highlight]\n \n Projects list file format\n ~~~~~~~~~~~~~~~~~~~~~~~~~\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex a85e2f6..e5910ce 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -165,6 +165,12 @@ our @diff_opts = ('-M'); # taken from git_commit\n # the gitweb domain.\n our $prevent_xss = 0;\n \n+# Path to the highlight executable to use (must be the one from\n+# http://www.andre-simon.de due to assumptions about parameters and output).\n+# Useful if highlight is not installed on your webserver's PATH.\n+# [Default: highlight]\n+our $highlight_bin = \"++HIGHLIGHT_BIN++\";\n+\n # information about snapshot formats that gitweb is capable of serving\n our %known_snapshot_formats = (\n \t# name => {\n@@ -3360,7 +3366,8 @@ sub run_highlighter {\n \tclose $fd\n \t\tor die_error(404, \"Reading blob failed\");\n \topen $fd, quote_command(git_cmd(), \"cat-file\", \"blob\", $hash).\" | \".\n-\t          \"highlight --xhtml --fragment --syntax $syntax |\"\n+\t          quote_command($highlight_bin).\n+\t          \" --xhtml --fragment --syntax $syntax |\"\n \t\tor die_error(500, \"Couldn't open file or run syntax highlighter\");\n \treturn $fd;\n }\n-- \n1.7.2.3\n"},{"id":"151234","messageId":"201009212109.41676.jnareb@gmail.com","threadId":"25163","inReplyTo":"4C985DDF.8060807@cdwilson.us","subject":"Re: [PATCH] Enable highlight executable path as a configuration option","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-09-21T19:09:40Z","receivedAt":"2010-09-21T19:09:40Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Tue, 21 Sep 2010, Christopher Wilson wrote:\n\n> Jakub, thanks for the helpful feedback.  I included the updated patch\n> (see below) which includes the changes you suggested. \n\n> -- >8 --\n> Subject: [PATCH] Enable highlight executable path as a configuration option\n> \n> Allow build-time/run-time configuration of the highlight executable\n> (must be the one from http://www.andre-simon.de due to assumptions\n> about parameters and output).  Defaults to previous behavior which\n> assumes that highlight is available on the server PATH. However, if\n> this is not the case, the path to the highlight executable can be\n> configured at build time as a configuration variable\n> \n>     HIGHLIGHT_BIN = /path/to/highlight\n> \n> or at runtime by configuring GITWEB_CONFIG\n> \n>     $highlight_bin = /path/to/highlight\n> \n> Signed-off-by: Christopher Wilson <cwilson@cdwilson.us>\n\nFor what it is worth it:\n\nAcked-by: Jakub Narebski <jnareb@gmail.com>\n\nIt would certainly be nice to have tests for $highlight_bin, but even\nassuming that HIGHLIGHT prerequisite is met, I don't know how such test\ncould be written.  It is not a show-stopper.\n\n-- \nJakub Narebski\nPoland\n"}]}