| | @@ -495,10 +495,35 @@ |
| 495 | 495 | if( c=='.' ){ |
| 496 | 496 | if( z[1]=='/' || z[1]==0 ) return 0; |
| 497 | 497 | if( z[1]=='.' && (z[2]=='/' || z[2]==0) ) return 0; |
| 498 | 498 | } |
| 499 | 499 | for(i=0; (c=z[i])!=0; i++){ |
| 500 | + if( (c & 0xf0) == 0xf0 ) { |
| 501 | + /* Unicode characters > U+FFFF are not supported. |
| 502 | + * Windows XP and earlier cannot handle them. |
| 503 | + */ |
| 504 | + return 0; |
| 505 | + } |
| 506 | + if( (c & 0xf0) == 0xe0 ) { |
| 507 | + /* This is a 3-byte UTF-8 character */ |
| 508 | + if ( (c & 0xfe) == 0xee ){ |
| 509 | + /* Range U+E000 - U+FFFF (Starting with 0xee or 0xef in UTF-8 ) */ |
| 510 | + if ( (c & 1) && ((z[i+1] & 0xff) >= 0xa4) ){ |
| 511 | + /* But exclude U+F900 - U+FFFF (0xef followed by byte >= 0xa4), |
| 512 | + * which contain valid characters. */ |
| 513 | + continue; |
| 514 | + } |
| 515 | + /* Unicode character in the range U+E000 - U+F8FF are for |
| 516 | + * private use, they shouldn't occur in filenames. */ |
| 517 | + return 0; |
| 518 | + } |
| 519 | + if( ((c & 0xff) == 0xed) && ((z[i+1] & 0xe0) == 0xa0) ){ |
| 520 | + /* Unicode character in the range U+D800 - U+DFFF are for |
| 521 | + * surrogate pairs, they shouldn't occur in filenames. */ |
| 522 | + return 0; |
| 523 | + } |
| 524 | + } |
| 500 | 525 | if( c=='\\' || c=='*' || c=='[' || c==']' || c=='?' ){ |
| 501 | 526 | return 0; |
| 502 | 527 | } |
| 503 | 528 | if( c=='/' ){ |
| 504 | 529 | if( z[i+1]=='/' ) return 0; |
| 505 | 530 | |