diff --git a/libvips/foreign/dzsave.c b/libvips/foreign/dzsave.c index 2e82e8a9..77c9c984 100644 --- a/libvips/foreign/dzsave.c +++ b/libvips/foreign/dzsave.c @@ -1759,14 +1759,20 @@ vips_foreign_save_dz_build( VipsObject *object ) *p = '\0'; if( (p = strrchr( dz->basename, '.' )) ) { /* If we're writing to thing.zip or thing.szi, default to zip - * container. Strip the file extension then. + * container. */ - if( !vips_object_argument_isset( object, "container" ) ) + if( !vips_object_argument_isset( object, "container" ) ) if( strcasecmp( p + 1, "zip" ) == 0 || - strcasecmp( p + 1, "szi" ) == 0 ) { - *p = '\0'; + strcasecmp( p + 1, "szi" ) == 0 ) dz->container = VIPS_FOREIGN_DZ_CONTAINER_ZIP; - } + + /* Always remove .szi, .zip, .dz. We don't remove all suffixes + * since we might be writing to a dirname with a dot in. + */ + if( strcasecmp( p + 1, "zip" ) == 0 || + strcasecmp( p + 1, "szi" ) == 0 || + strcasecmp( p + 1, "dz" ) == 0 ) + *p = '\0'; } } @@ -1993,7 +1999,7 @@ static int bandfmt_dz[10] = { UC, C, US, S, UI, I, F, F, D, D }; -const char *dz_suffs[] = { ".dz", NULL }; +static const char *dz_suffs[] = { ".dz", NULL }; static void vips_foreign_save_dz_class_init( VipsForeignSaveDzClass *class )