File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -398,6 +398,10 @@ namespace sharp {
398
398
// From filesystem
399
399
imageType = DetermineImageType (descriptor->file .data ());
400
400
if (imageType == ImageType::MISSING) {
401
+ if (descriptor->file .find (" <svg" ) != std::string::npos) {
402
+ throw vips::VError (" Input file is missing, did you mean "
403
+ " sharp(Buffer.from('" + descriptor->file .substr (0 , 8 ) + " ...')?" );
404
+ }
401
405
throw vips::VError (" Input file is missing" );
402
406
}
403
407
if (imageType != ImageType::UNKNOWN) {
Original file line number Diff line number Diff line change @@ -135,4 +135,11 @@ describe('SVG input', function () {
135
135
assert . strictEqual ( info . height , 240 ) ;
136
136
assert . strictEqual ( info . channels , 4 ) ;
137
137
} ) ;
138
+
139
+ it ( 'Detects SVG passed as a string' , ( ) =>
140
+ assert . rejects (
141
+ ( ) => sharp ( '<svg></svg>' ) . toBuffer ( ) ,
142
+ / I n p u t f i l e i s m i s s i n g , d i d y o u m e a n /
143
+ )
144
+ ) ;
138
145
} ) ;
You can’t perform that action at this time.
0 commit comments