Fossil SCM
Handle file names containing brackets, interrogation mark or asterisk
d17d6e5b174bd6f…
· opened 15 years, 9 months ago
- Type
- Code_Defect
- Priority
- —
- Severity
- Minor
- Resolution
- Fixed
- Subsystem
- —
- Created
- June 25, 2010 5:24 a.m.
I am trying to version some Microsoft OpenXML files (docx, xlsx, pptx) that are zipped archives.
A file in the archive is typically named [Content-Types].xml with those brackets.
Fossil refuses to handle this file. I think this is because there are GLOB operations in the source code having looked it up quickly.
But I am pretty sure it is possible with SQLite to GLOB 'a\?b' ESCAPE '\'
Thank you for understanding this issue.
anonymous claiming to be benoit added on 2010-06-25 05:26:32:
the hyperlink in the ticket description is actually text surrounded with brackets…
jan.nijtmans added on 2012-11-20 13:47:51 UTC: Highly experimental fix for this committed in [82ce90f91c]. Should get a lot more testing before going into trunk
Feedback welcome.
anonymous added on 2012-11-20 15:18:47 UTC:
char *fossil_unicode_to_utf8(void *zUnicode){
#ifdef _WIN32
int nByte = 0;
char *zUtf;
WCHAR *wUnicode = zUnicode;
/*
This my have problem when zUnicode is readonly.
And it's will modify zUnicode when sometimes we did not want to modify it.
*/
while( *wUnicode != 0 ){
if ( (*wUnicode > 0xF000) && (*wUnicode <= 0xF07F) ){
*wUnicode &= 0x7F;
}
++wUnicode;
}
nByte = WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, 0, 0, 0, 0);
zUtf = sqlite3_malloc( nByte );
if( zUtf==0 ){
return 0;
}
WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, zUtf, nByte, 0, 0);
return zUtf;
#else
return (char *)zUnicode; /* No-op on unix */
#endif
}
void *fossil_utf8_to_unicode(const char *zUtf8){
#ifdef _WIN32
/* nWord should be meaningful than nByte here*/
int nByte = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, 0, 0);
wchar_t *zUnicode = sqlite3_malloc( nByte * 2 );
wchar_t *wUnicode;
if( zUnicode==0 ){
return 0;
}
MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nByte);
wUnicode = zUnicode;
while( --nByte > 0){
if ( (*wUnicode < 32) || wcschr(L"\"*<>?|", *wUnicode) ){
*wUnicode |= 0xF000;
}
++wUnicode;
}
return zUnicode;
#else
return (void *)zUtf8; /* No-op on unix */
#endif
}
anonymous added on 2012-11-20 15:23:31 UTC:
char *fossil_unicode_to_utf8(void *zUnicode){
#ifdef _WIN32
int nByte = 0;
char *zUtf;
WCHAR *wUnicode = zUnicode;
/*
This my have problem when zUnicode is readonly.
And it's will modify zUnicode when sometimes we did not want to modify it.
*/
while( *wUnicode != 0 ){
if ( (*wUnicode > 0xF000) && (*wUnicode <= 0xF07F) ){
*wUnicode &= 0x7F;
}
++wUnicode;
}
nByte = WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, 0, 0, 0, 0);
zUtf = sqlite3_malloc( nByte );
if( zUtf==0 ){
return 0;
}
WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, zUtf, nByte, 0, 0);
return zUtf;
#else
return (char *)zUnicode; /* No-op on unix */
#endif
}
void *fossil_utf8_to_unicode(const char *zUtf8){
#ifdef _WIN32
/* nWord should be meaningful than nByte here*/
int nByte = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, 0, 0);
wchar_t *zUnicode = sqlite3_malloc( nByte * 2 );
wchar_t *wUnicode;
if( zUnicode==0 ){
return 0;
}
MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nByte);
wUnicode = zUnicode;
while( --nByte > 0){
if ( (*wUnicode < 32) || wcschr(L"\"*<>?|", *wUnicode) ){
*wUnicode |= 0xF000;
}
++wUnicode;
}
return zUnicode;
#else
return (void *)zUtf8; /* No-op on unix */
#endif
}