git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH/RFC] gitweb: highlight: strip non-printable characters via col(1)

From
Christopher M. Fuhrman <cfuhrman@panix.com>
Date
Aug 16, 2011, 21:32 UTC
Message-ID
<alpine.NEB.2.01.1108161414030.7527@vc75.vc.panix.com>
In-Reply-To
<4E4AD35E.8060907@eaglescrag.net>
On Tue, 16 Aug 2011 at 1:30pm, J.H. wrote:
Show 7 quoted lines
> On 08/16/2011 11:16 AM, Christopher M. Fuhrman wrote:
> > From: "Christopher M. Fuhrman" <cfuhrman@panix.com>
> >
> > The current code, as is, passes control characters, such as form-feed
> > (^L) to highlight which then passes it through to the browser.  This
> > will cause the browser to display one of the following warnings:
> >
<snip>
Show 10 quoted lines
> > Strip non-printable control-characters by piping the output produced
> > by git-cat-file(1) to col(1) as follows:
> >
> >   git cat-file blob deadbeef314159 | col -bx | highlight <args>
>
> So my only real concern here is that `col` itself is going to munge
> whitespace.  Quoting from the col man page:
>
> 	[...] and replaces white-space characters with tabs where
> 	    possible. [...]

I figured that would be a concern which is why I added the -x option. From the col(1) man page:

  -x        Output multiple spaces instead of tabs.

I also took a diff between two XHTML files. One that used col -bx and one that didn't. Here's the results:

--- withoutcol.xhtml 2011-08-16 14:11:39.000000000 -0700 +++ withcol.xhtml 2011-08-16 14:11:26.000000000 -0700

@@ -52,7 +52,7 @@
 <span class="hl dir"># define DBG_CFG(args)</span>
 <span class="hl dir">#endif</span>

-
+
 <span class="hl com">/*</span>
 <span class="hl com"> * Routines to access TIG registers.</span>
 <span class="hl com"> */</span>
@@ -76,7 +76,7 @@
         <span class="hl sym">*</span>tig_addr <span class="hl sym">= (</span><span class="hl kwb">unsigned long</span><span class="hl sym">)</span>value<span class="hl sym">;</span>
 <span class="hl sym">}</span>

-
+
 <span class="hl com">/*</span>
 <span class="hl com"> * Given a bus, device, and function number, compute resulting</span>
 <span class="hl com"> * configuration space address</span>
@@ -197,7 +197,7 @@
         <span class="hl sym">.</span>write <span class="hl sym">=</span>        titan_write_config<span class="hl sym">,</span>
 <span class="hl sym">};</span>

(remainder stripped)

>
> Have you actually run into a situation where something like ^L was
> present in a blob that was being passed to highlight?
>

I've seen ^L is the Linux kernel source tree as well as the NetBSD src
tree.  I've not encountered it elsewhere although I would think it would
be present depending on personal/corporate coding preferences.

> - John

Cheers!
-- 
Chris Fuhrman
cfuhrman@panix.com
Previous: J.H.
Message 3 of 3 in “gitweb: highlight: strip non-printable characters via col(1)”
  1. gitweb: highlight: strip non-printable characters via col(1)Christopher M. Fuhrman, Aug 16, 2011
  2. J.H.Aug 16, 2011
  3. Christopher M. FuhrmanAug 16, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.