Bug 118550 - CGI kioslave adds random space!
Summary: CGI kioslave adds random space!
Status: RESOLVED FIXED
Alias: None
Product: kio
Classification: Frameworks and Libraries
Component: cgi (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Cornelius Schumacher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-18 02:40 UTC by Tim Hutt
Modified: 2006-06-24 08:17 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Fix slightly corrupted output in CGI kioslave. (3.17 KB, patch)
2006-06-21 02:47 UTC, Michael Pyne
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Hutt 2005-12-18 02:40:47 UTC
Version:            (using KDE KDE 3.5.0)
Installed from:    Ubuntu Packages
OS:                Linux

Ok, I spend ages trying to find a bug in my code but it turns out to be a bug in the cgi kioslave.

Useful as it is, GRRRRRRRRRRRRR!

The problem is that it adds a random space somewhere in the output, which breaks the HTML if it is in the wrong place, and is almost impossible to debug.
Comment 1 Michael Pyne 2006-06-21 02:44:34 UTC
I can confirm this.  The problem is that there is code to try and extract the Content-Type, which uses QCString (a subclass of QByteArray).  The QCString has the property that it always ends in '\0'.  (i.e. [ d, a, t, a, \0 ]).  When the QCString buffer is later transferred to KIO, KIO sends all of it, including the trailing '\0' which was not there before.

I will attach a patch which fixes the issue (at least in my testing).  At first I was just going to convert back to a QByteArray and send the plain QByteArray, but the underlying issue is that QCString is designed for text, not binary data, so I decided to fix that instead.  It is understandably more invasive that way so I would like to get the patch reviewed before committing.
Comment 2 Michael Pyne 2006-06-21 02:47:07 UTC
Created attachment 16733 [details]
Fix slightly corrupted output in CGI kioslave.

This patch fixes the issue by using QByteArray for everything dealing with the
data from the buffer we're reading into.
Comment 3 Michael Pyne 2006-06-24 08:17:51 UTC
This is fixed in KDE 3.5, fix will be included in the next release.

KDE 4 seems to be unaffected thanks to the API changes in Qt, so no patch was applied there.