Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When a zip file is downloaded through the module's chr_curl_http_request() function, the file gets corrupted because at line 183 the spaces from the response received are trimmed.
// Make request.
$result->data = trim(curl_exec($ch));
We suggest that trim should be removed. We can send you a small patch for this.
Comment | File | Size | Author |
---|---|---|---|
#2 | chr-ltrim-response-2816399-1.patch | 395 bytes | Cyberwolf |
PastedGraphic-1.png | 10.02 KB | ionut.stan |
Comments
Comment #2
Cyberwolf CreditAttribution: Cyberwolf at 2DotsTwice bvba for European Commission and European Union Institutions, Agencies and Bodies commentedAttaching a patch. It replaces trim() with ltrim().
Comment #3
gboddin CreditAttribution: gboddin at European Commission and European Union Institutions, Agencies and Bodies commentedThis is true for all files ending with null characters, I would even raise the priority a bit.
Eg : 000bdf0 0000 0000 0054 0000 1000 0000 0000 0000 in our case was the end of an excel file ( and obviously the 3 last bytes got trim'd ).
Lots of software might use null termination as a delimiter, so this probably affects a few people, especially when doing migrations.
Seems to me ltrim is the right choice since the end of ->data will always be then end of the body.
Comment #4
gboddin CreditAttribution: gboddin at European Commission and European Union Institutions, Agencies and Bodies commentedComment #5
xrxphawxby CreditAttribution: xrxphawxby commented+1 to getting this merged and deployed, the patch is good.
I spent a day trying to figure out why my zip files were getting inexplicably corrupted.
Comment #6
amoebanath CreditAttribution: amoebanath at ComputerMinds commentedWhat a crazy issue!
Patch works nicely :)
Comment #7
PolSame goes for us.
Comment #9
Vincenzo CreditAttribution: Vincenzo as a volunteer commentedCommitted.
Comment #10
PolThanks!