From: Christopher M. Fuhrman Date: Tue, 16 Aug 2011 21:32:12 GMT Subject: Re: [PATCH/RFC] gitweb: highlight: strip non-printable characters via col(1) Message-ID: In-Reply-To: <4E4AD35E.8060907@eaglescrag.net> On Tue, 16 Aug 2011 at 1:30pm, J.H. wrote: > On 08/16/2011 11:16 AM, Christopher M. Fuhrman wrote: > > From: "Christopher M. Fuhrman" > > > > 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: > > > > 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 > > 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 @@ # define DBG_CFG(args) #endif - + /* * Routines to access TIG registers. */ @@ -76,7 +76,7 @@ *tig_addr = (unsigned long)value; } - + /* * Given a bus, device, and function number, compute resulting * configuration space address @@ -197,7 +197,7 @@ .write = titan_write_config, }; (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