View Ticket
Not logged in
2008-11-20
00:36 Fixed ticket [c62fac40af]: Edit CSS/HTML in Setup adds extra CR/LF, wrong http Content-length plus 1 other change artifact: e3d3a3ce3f user: drh
00:35
Here is a better fix for ticket [c62fac40af] suggested by Kees Nuyt. check-in: 22cb1e1be2 user: drh tags: trunk
2008-11-19
23:52 Open ticket [c62fac40af]: Edit CSS/HTML in Setup adds extra CR/LF, wrong http Content-length plus 1 other change artifact: eb6a9f18bf user: anonymous
2008-11-18
02:28 Fixed ticket [c62fac40af]. artifact: f28d6d6bb9 user: drh
02:21
Omit the Content-Length header line from the CGI response under windows because subsequent \n to \r\n translations by Apache will change the content length. But keep the Content-Length header line for the built-in servers and under unix. Ticket [c62fac40af0]. check-in: f6a071cef1 user: drh tags: trunk
2008-11-17
22:04 Ticket [c62fac40af] Edit CSS/HTML in Setup adds extra CR/LF, wrong http Content-length status still Open with 4 other changes artifact: 0582023acc user: anonymous
2008-09-02
14:02 New ticket [c62fac40af]. artifact: 727fdd03f3 user: anonymous

Ticket UUID: c62fac40af0860d28ad287cb3f203581e00fc9c8
Title: Edit CSS/HTML in Setup adds extra CR/LF, wrong http Content-length
Status: Fixed Type: Code_Defect
Severity: Important Priority: Low
Subsystem: Resolution: Fixed
Last Modified: 2008-11-20 00:36:37
Version Found In: [b3ee50c946] 2008-07-15, [ed5179db1f] 2008-11-15 21:17:31
Description & Comments:
While editing CSS and HTML in Fossil Setup, extra CR/LF pairs are added to the text box and the calculation of the http Content-length header is wrong (as if those extra CR/LF pairs weren't added), so some content is dropped at the end of the webpage. I'm not sure what's the cause, it might be an apache-CGI problem.

Environment: Running Fossil version [b3ee50c946] 2008-07-15 19:03:42 on Windows as CGI handler under Apache/2.2.6 (Win32), Server built: Sep 5 2007 08:58:56.

Observed with Firefox and IE7 on Windows.

The local fossil server http://127.0.0.1:8080/setup_editcss works as expected.

I'm not sure this is related, but for many fossil generated pages, the apache httpd error log shows lines like:

[Tue Sep 02 14:32:09 2008] [error] [client my.ip.add.ress] , referer: http://sub.domain.tld/fossil/sqlite/setup_editcss

but the access log seems ok:

my.ip.add.ress - - [02/Sep/2008:14:32:09 +0200] "GET /fossil/sqlite/setup_editcss HTTP/1.1" 200 8802

I would like to try with the more recent Fossil version [4b56350ecb] 2008-07-24 15:08:13, but it isn't available for download as a prebuild Win32 binary, and I don't have a build infrastructure here.


anonymous added on 2008-11-17 22:04:21:
It's not just the edit CSS in setup that shows it, other pages suffer as well, e.g. Timeline. It is easily detected by truncation of the fossil standard footer.

I do have a build infrastructure now (MSYS/MingW on Windows), and I did research some sources, but I can't point at the exact error.


drh added on 2008-11-18 02:28:09:
The fix in check-in [f6a071cef1] works for me on WinXP running under VMWare.


anonymous added on 2008-11-19 23:52:05:
Thanks for the fix, drh.

  • Bad news: I'm afraid it didn't really fix it. The contents of the EditCSS textbox still have extra \r , so line spacing increases by one after every edit.
  • Good news: stdout can be made binary with setmode(), which prevents the \n to \r\n translation.
Patches for main.c:

{line 30, in header includes}
= #include <time.h>
+ #ifdef __MINGW32__
+ /* Define file mode constants */
+ #include <fcntl.h>
+ #endif

{line 615, in cmd_cgi() }
=  g.httpOut = stdout;
+ #ifdef __MINGW32__
+   /* prevent \n to \r \n translation on Windows */
+   setmode( _fileno(g.httpOut), _O_BINARY );
+ #endif

The workaround in cgi.c, function cgi_reply() , is no longer necessary; the content-length header is valid.

Full diffs will be posted on the fossil-users mailing list.

Environment: Windows Vista, Apache httpd 2.2.9, mod_cgi, fossil [63886daad8] 2008-11-18 15:33:25 UTC