]> granicus.if.org Git - php/commitdiff
- #41609, file_put_contents is not binary safe when a binary string is
authorPierre Joye <pajoye@php.net>
Thu, 14 Jun 2007 19:56:35 +0000 (19:56 +0000)
committerPierre Joye <pajoye@php.net>
Thu, 14 Jun 2007 19:56:35 +0000 (19:56 +0000)
  given (make it consistent with fwrite&co when unicode=1)

ext/standard/file.c

index b1c7bae415e83b94bf09b121c2d3d58418c09849..375555bc409820ff87b85d74bfb7de5e8a7d4744 100644 (file)
@@ -646,7 +646,7 @@ PHP_FUNCTION(file_put_contents)
        if (flags & PHP_FILE_APPEND) {
                mode[0] = 'a';
        }
-       if (flags & PHP_FILE_BINARY) {
+       if (flags & PHP_FILE_BINARY || (Z_TYPE_P(data) == IS_STRING)) {
                mode[1] = 'b';
        } else if (flags & PHP_FILE_TEXT) {
                mode[1] = 't';