how to check if a string is valid gzdeflated string ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
madrazel
Forum Newbie
Posts: 7
Joined: Wed Sep 09, 2009 9:24 am

how to check if a string is valid gzdeflated string ?

Post by madrazel »

the problem is that gzdeflate function does not return false when there is an error with the string, that is if in example this string was compressed with another compressor not compatible with gzdeflate or is just a random string without any information contained
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: how to check if a string is valid gzdeflated string ?

Post by John Cartwright »

There are different implementations of gzip, so you need to make sure your gzip is using the same compression algorithm.

For instance, if you are trying to decode an HTTP gzip'd response, you'll want to use gzuncompress (HTTP and gzuncompress both use zlib).

I'm not expert on the matter, but I would suspect this is why no error is being triggered.
Post Reply