Bug 692266

Summary: cgit syntax-highlighting script has issues with highlight > 3.x
Product: [Fedora] Fedora Reporter: Joel Uckelman <uckelman>
Component: cgitAssignee: Todd Zullinger <tmz>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 14CC: dcallagh, jochen, smithj4, tmz
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-16 16:32:14 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Joel Uckelman 2011-03-30 21:03:15 UTC
Description of problem:

The /usr/libexec/cgit/filters/syntax-highlighting.sh script used by cgit for source highlighting calls the highlight command with the -X option, but the version of highlight in F14 (3.1-2) has no -X option. This causes the script to fail.

Version-Release number of selected component (if applicable):

cgit-0.9-1.fc14.x86_64


How reproducible:

Always.


Steps to Reproduce:
1. Enable syntax highlighting in /etc/cgitrc.
2. Browse to a source file.
  
Actual results:

The page comes up with an Internal Server error the first time, and then a link to the raw file on subsequent tries.

Expected results:

The page should show a syntax-highlighted version of the file.


Additional info:

Removing the -X option from syntax-highlighting.sh fixes the problem.

Comment 1 Todd Zullinger 2011-04-13 18:14:26 UTC
Removing the option fixes one problem, but highlight has changed significantly (and in a non-backward-compatible way) with version 3.  If you browse to a file that lacks an extension or has an extension for which highlight lacks a language file, it now produces an error and does not output any text -- despite the --force option.  For example:

$ echo foo | highlight --force -f -I -S foo
highlight: Lua error ( cannot open /usr/share/highlight/langDefs/foo.lang: No such file or directory ) in foo.lang

Older highlight handles this properly, IMO:

$ echo foo | highlight --force -f -I -S foo
highlight: Unknown source file extension "foo".
foo

The error is on stderr, which cgit's syntax highlighting script redirects to /dev/null.  But at least the output is included.

I'm open to ideas on how to properly handle this.  I'm of the opinion that this should be fixed upstream in highlight.  I'm adding the highlight maintainer to the Cc.

For reference, the cgit source highlight script from cgit-0.9:

http://hjemli.net/git/cgit/tree/filters/syntax-highlighting.sh?id=v0.9

I started working on some patches for this script, but the issue of highlight not handling missing/unknown language files is an ugly one to fix in third-party scripts.

Comment 2 Joel Uckelman 2011-04-13 20:40:54 UTC
I concur. It would be better if the problem were fixed in highlight.

Comment 3 Jason Smith 2011-10-10 20:35:51 UTC
The --force option appears to be fixed in highlight 3.5, from the changelog:

02.06.2011
-fixed --force option (thanks to Stefan Bühler)

So, updating the highlight package and fixing the syntax-highlighting.sh script in cgit to replace "-X" with "-O xhtml" should fix the original problem.

Since the new version of highlight supports automatic file-type detection by looking at the shebang line I believe, I tried omitting the "-S $EXTENSION" option.  It does seem to work sometimes, but I also get script execution failures occasionally, which I traced to highlight Segmentation faults when it cannot detect the file type.  Some examples, if the first line contains:

1. #!/bin/bash  --> works!
2. #!/usr/bin/perl -w  -->  Segmentation fault!
3. #!/usr/bin/perl  --> No segfault, but not highlighted.

Some types that it should know, it frequently reports:

highlight: Unknown source file extension "py".

and it doesn't add highlighting.  Other times it produces an error like:

highlight: Undefined language definition. Use --syntax option.
Segmentation fault (core dumped)

Comment 4 Fedora End Of Life 2012-08-16 16:32:17 UTC
This message is a notice that Fedora 14 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 14. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained.  At this time, all open bugs with a Fedora 'version'
of '14' have been closed as WONTFIX.

(Please note: Our normal process is to give advanced warning of this 
occurring, but we forgot to do that. A thousand apologies.)

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, feel free to reopen 
this bug and simply change the 'version' to a later Fedora version.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we were unable to fix it before Fedora 14 reached end of life. If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora, you are encouraged to click on 
"Clone This Bug" (top right of this page) and open it against that 
version of Fedora.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping