Kaydet (Commit) 9b9e5cfd authored tarafından Gökhan Gurbetoğlu's avatar Gökhan Gurbetoğlu Kaydeden (comit) jan iversen

tdf#99589 - tolower / toupper - dangerous to Turks ...

Change-Id: I8b0fe9354232a7b60f3605fa6f90f6741f7bf683
Reviewed-on: https://gerrit.libreoffice.org/26537Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarjan iversen <jani@documentfoundation.org>
üst 8ab7db32
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "sbunoobj.hxx" #include "sbunoobj.hxx"
#include <math.h> #include <math.h>
#include <ctype.h> #include <ctype.h>
#include <rtl/character.hxx>
#include <com/sun/star/uno/XInterface.hpp> #include <com/sun/star/uno/XInterface.hpp>
using namespace com::sun::star::uno; using namespace com::sun::star::uno;
...@@ -350,7 +351,7 @@ sal_uInt16 SbxVariable::MakeHashCode( const OUString& rName ) ...@@ -350,7 +351,7 @@ sal_uInt16 SbxVariable::MakeHashCode( const OUString& rName )
{ {
return 0; return 0;
} }
n = sal::static_int_cast< sal_uInt16 >( ( n << 3 ) + toupper( c ) ); n = sal::static_int_cast< sal_uInt16 >( ( n << 3 ) + rtl::toAsciiUpperCase( c ) );
} }
return n; return n;
} }
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <comphelper/oslfile2streamwrap.hxx> #include <comphelper/oslfile2streamwrap.hxx>
#include <rtl/ref.hxx> #include <rtl/ref.hxx>
#include <rtl/character.hxx>
using namespace ::cppu; using namespace ::cppu;
using namespace ::osl; using namespace ::osl;
...@@ -679,14 +680,14 @@ tnode T602ImportFilter::PointCmd602(unsigned char *ch) ...@@ -679,14 +680,14 @@ tnode T602ImportFilter::PointCmd602(unsigned char *ch)
char pcmd[2]; char pcmd[2];
// warning: uChar -> char // warning: uChar -> char
pcmd[0] = (char) toupper(*ch); inschr(*ch); pcmd[0] = (char) rtl::toAsciiUpperCase(*ch); inschr(*ch);
*ch = Readchar602(); *ch = Readchar602();
if (!*ch) return tnode::EEND; if (!*ch) return tnode::EEND;
if (*ch=='\n') return tnode::EOL; if (*ch=='\n') return tnode::EOL;
if (!isalpha(*ch)) return (*ch<32) ? tnode::SETCH : tnode::WRITE; if (!isalpha(*ch)) return (*ch<32) ? tnode::SETCH : tnode::WRITE;
// warning: uChar -> char // warning: uChar -> char
pcmd[1] = (char) toupper(*ch); inschr(*ch); pcmd[1] = (char) rtl::toAsciiUpperCase(*ch); inschr(*ch);
if (pcmd[0]=='P' && pcmd[1]=='A') { if (pst.pars) pst.willbeeop = true; } if (pcmd[0]=='P' && pcmd[1]=='A') { if (pst.pars) pst.willbeeop = true; }
else if (pcmd[0]=='C' && pcmd[1]=='P') { if (pst.pars) pst.willbeeop = true; } else if (pcmd[0]=='C' && pcmd[1]=='P') { if (pst.pars) pst.willbeeop = true; }
...@@ -761,12 +762,12 @@ void T602ImportFilter::Read602() ...@@ -761,12 +762,12 @@ void T602ImportFilter::Read602()
case tnode::EXPCMD: ch = Readchar602(); case tnode::EXPCMD: ch = Readchar602();
if(ch == 0) {inschr('@'); node = tnode::EEND; } if(ch == 0) {inschr('@'); node = tnode::EEND; }
else if(isupper(ch)) { else if(rtl::isAsciiUpperCase(ch)) {
cmd602[0] = ch; cmd602[0] = ch;
ch = Readchar602(); ch = Readchar602();
cmd602[1] = ch; cmd602[1] = ch;
cmd602[2] = '\0'; cmd602[2] = '\0';
if(isupper(ch)) if(rtl::isAsciiUpperCase(ch))
node = tnode::SETCMD; //nedodelano node = tnode::SETCMD; //nedodelano
else { else {
inschr('@'); inschr('@');
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <libxml/catalog.h> #include <libxml/catalog.h>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <rtl/character.hxx>
#include <osl/thread.h> #include <osl/thread.h>
#include <osl/process.h> #include <osl/process.h>
#include <osl/file.hxx> #include <osl/file.hxx>
...@@ -249,7 +250,7 @@ private: ...@@ -249,7 +250,7 @@ private:
inline char tocharlower(char c) inline char tocharlower(char c)
{ {
return static_cast<char>(tolower(c)); return static_cast<char>(rtl::toAsciiLowerCase(c));
} }
#endif #endif
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include "drawdef.h" #include "drawdef.h"
#include "hcode.h" #include "hcode.h"
#include <rtl/character.hxx>
int HBox::boxCount = 0; int HBox::boxCount = 0;
HBox::HBox(hchar hch) HBox::HBox(hchar hch)
...@@ -586,7 +588,7 @@ static void getOutlineNumStr(int style, int level, int num, hchar * hstr) ...@@ -586,7 +588,7 @@ static void getOutlineNumStr(int style, int level, int num, hchar * hstr)
ptr = buf; ptr = buf;
while (*ptr) while (*ptr)
{ {
*ptr = sal::static_int_cast<char>(toupper(*ptr)); *ptr = sal::static_int_cast<char>(rtl::toAsciiUpperCase(*ptr));
ptr++; ptr++;
} }
} }
...@@ -688,7 +690,7 @@ hchar_string Outline::GetUnicode() const ...@@ -688,7 +690,7 @@ hchar_string Outline::GetUnicode() const
char *ptr = dest; char *ptr = dest;
while( *ptr ) while( *ptr )
{ {
*ptr = sal::static_int_cast<char>(toupper(*ptr)); *ptr = sal::static_int_cast<char>(rtl::toAsciiUpperCase(*ptr));
ptr++; ptr++;
} }
} }
......
...@@ -32,6 +32,8 @@ using namespace std; ...@@ -32,6 +32,8 @@ using namespace std;
#include <sal/types.h> #include <sal/types.h>
#include <sal/macros.h> #include <sal/macros.h>
#include <rtl/character.hxx>
/* @Man: change the hwp formula to LaTeX */ /* @Man: change the hwp formula to LaTeX */
#ifdef _WIN32 #ifdef _WIN32
# define ENDL "\r\n" # define ENDL "\r\n"
...@@ -416,15 +418,15 @@ void make_keyword( char *keyword, const char *token) ...@@ -416,15 +418,15 @@ void make_keyword( char *keyword, const char *token)
memcpy(keyword, token, len); memcpy(keyword, token, len);
keyword[len] = 0; keyword[len] = 0;
if( (token[0] & 0x80) || islower(token[0]) || strlen(token) < 2 ) if( (token[0] & 0x80) || rtl::isAsciiLowerCase(token[0]) || strlen(token) < 2 )
return; return;
int capital = isupper(keyword[1]); int capital = rtl::isAsciiUpperCase(keyword[1]);
for( ptr = keyword + 2; *ptr && result; ptr++ ) for( ptr = keyword + 2; *ptr && result; ptr++ )
{ {
if( (*ptr & 0x80) || if( (*ptr & 0x80) ||
(!capital && isupper(*ptr)) || (!capital && rtl::isAsciiUpperCase(*ptr)) ||
(capital && islower(*ptr)) ) (capital && rtl::isAsciiLowerCase(*ptr)) )
{ {
result = false; result = false;
} }
...@@ -435,8 +437,8 @@ void make_keyword( char *keyword, const char *token) ...@@ -435,8 +437,8 @@ void make_keyword( char *keyword, const char *token)
ptr = keyword; ptr = keyword;
while( *ptr ) while( *ptr )
{ {
if( isupper(*ptr) ) if( rtl::isAsciiUpperCase(*ptr) )
*ptr = sal::static_int_cast<char>(tolower(*ptr)); *ptr = sal::static_int_cast<char>(rtl::toAsciiLowerCase(*ptr));
ptr++; ptr++;
} }
} }
...@@ -687,8 +689,8 @@ static char eq2ltxconv(MzString& sstr, istream *strm, const char *sentinel) ...@@ -687,8 +689,8 @@ static char eq2ltxconv(MzString& sstr, istream *strm, const char *sentinel)
key[0] = '\\'; key[0] = '\\';
strcpy(key + 1, eq->key); strcpy(key + 1, eq->key);
} }
if( (eq->flag & EQ_CASE) && isupper(token[0]) ) if( (eq->flag & EQ_CASE) && rtl::isAsciiUpperCase(token[0]) )
key[1] = sal::static_int_cast<char>(toupper(key[1])); key[1] = sal::static_int_cast<char>(rtl::toAsciiUpperCase(key[1]));
token = key; token = key;
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include<rtl/character.hxx> #include <rtl/character.hxx>
using namespace std; using namespace std;
#include "gL10nMem.hxx" #include "gL10nMem.hxx"
...@@ -871,7 +871,7 @@ bool l10nMem::locateKey(int iLineNo, ...@@ -871,7 +871,7 @@ bool l10nMem::locateKey(int iLineNo,
if (ch == ' ' || ch == '*' || ch == '+' || ch == '%') if (ch == ' ' || ch == '*' || ch == '+' || ch == '%')
sUpperKey[i] = '_'; sUpperKey[i] = '_';
else else
sUpperKey[i] = toupper(sUpperKey[i]); sUpperKey[i] = rtl::toAsciiUpperCase(sUpperKey[i]);
} }
// Fast check, to see if next key is the one (normal with load and source without change) // Fast check, to see if next key is the one (normal with load and source without change)
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "osl/time.h" #include "osl/time.h"
#include "rtl/alloc.h" #include "rtl/alloc.h"
#include "rtl/ustring.hxx" #include "rtl/ustring.hxx"
#include <rtl/character.hxx>
#include <tchar.h> #include <tchar.h>
#ifdef __MINGW32__ #ifdef __MINGW32__
...@@ -1054,7 +1055,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector ...@@ -1054,7 +1055,7 @@ oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirector
osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl ); osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
_tcscpy( pItemImpl->cDriveString, strSysFilePath->buffer ); _tcscpy( pItemImpl->cDriveString, strSysFilePath->buffer );
pItemImpl->cDriveString[0] = toupper( pItemImpl->cDriveString[0] ); pItemImpl->cDriveString[0] = rtl::toAsciiUpperCase( pItemImpl->cDriveString[0] );
if ( pItemImpl->cDriveString[_tcslen(pItemImpl->cDriveString) - 1] != '\\' ) if ( pItemImpl->cDriveString[_tcslen(pItemImpl->cDriveString) - 1] != '\\' )
_tcscat( pItemImpl->cDriveString, TEXT( "\\" ) ); _tcscat( pItemImpl->cDriveString, TEXT( "\\" ) );
......
...@@ -69,6 +69,8 @@ ...@@ -69,6 +69,8 @@
#include "rtl/bootstrap.h" #include "rtl/bootstrap.h"
#include <rtl/character.hxx>
using namespace com::sun::star; using namespace com::sun::star;
namespace pdfi namespace pdfi
...@@ -469,8 +471,8 @@ sal_Int32 Parser::parseFontCheckForString( ...@@ -469,8 +471,8 @@ sal_Int32 Parser::parseFontCheckForString(
if (nCopyLen < nAttribLen) if (nCopyLen < nAttribLen)
return 0; return 0;
for (sal_Int32 i = 0; i < nAttribLen; ++i) for (sal_Int32 i = 0; i < nAttribLen; ++i)
if (tolower(pCopy[i]) != pAttrib[i] if (rtl::toAsciiLowerCase(pCopy[i]) != rtl::toAsciiLowerCase(pAttrib[i])
&& toupper(pCopy[i]) != pAttrib[i]) && rtl::toAsciiUpperCase(pCopy[i]) != rtl::toAsciiLowerCase(pAttrib[i]))
return 0; return 0;
rResult.isItalic |= bItalic; rResult.isItalic |= bItalic;
rResult.isBold |= bBold; rResult.isBold |= bBold;
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#include "collectdircontent.hxx" #include "collectdircontent.hxx"
#include <rtl/character.hxx>
using namespace std; using namespace std;
...@@ -29,7 +30,7 @@ void IncludesCollection::add_to_collection(const string& dirPath) { ...@@ -29,7 +30,7 @@ void IncludesCollection::add_to_collection(const string& dirPath) {
} }
do { do {
string winFileName(FindFileData.cFileName); string winFileName(FindFileData.cFileName);
transform(winFileName.begin(), winFileName.end(), winFileName.begin(), ::tolower); transform(winFileName.begin(), winFileName.end(), winFileName.begin(), rtl::toAsciiLowerCase);
dirContent.insert(winFileName); dirContent.insert(winFileName);
} while (FindNextFile(hFind, &FindFileData)); } while (FindNextFile(hFind, &FindFileData));
#else #else
...@@ -51,7 +52,7 @@ void IncludesCollection::add_to_collection(const string& dirPath) { ...@@ -51,7 +52,7 @@ void IncludesCollection::add_to_collection(const string& dirPath) {
bool IncludesCollection::exists(string filePath) { bool IncludesCollection::exists(string filePath) {
#if defined(_WIN32) #if defined(_WIN32)
transform(filePath.begin(), filePath.end(), filePath.begin(), ::tolower); transform(filePath.begin(), filePath.end(), filePath.begin(), rtl::toAsciiLowerCase);
#endif // defined( WNT ) #endif // defined( WNT )
PathFilePair dirFile = split_path(filePath); PathFilePair dirFile = split_path(filePath);
string dirPath = dirFile.first; string dirPath = dirFile.first;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <string.h> #include <string.h>
#include <rtl/strbuf.hxx> #include <rtl/strbuf.hxx>
#include <rtl/character.hxx>
#include <tools/stream.hxx> #include <tools/stream.hxx>
#include <tools/globname.hxx> #include <tools/globname.hxx>
...@@ -181,7 +182,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr ) ...@@ -181,7 +182,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr )
if( isdigit( *pStr ) ) if( isdigit( *pStr ) )
nFirst = nFirst * 16 + (*pStr - '0'); nFirst = nFirst * 16 + (*pStr - '0');
else else
nFirst = nFirst * 16 + (toupper( *pStr ) - 'A' + 10 ); nFirst = nFirst * 16 + (rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 );
else else
return false; return false;
pStr++; pStr++;
...@@ -195,7 +196,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr ) ...@@ -195,7 +196,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr )
if( isdigit( *pStr ) ) if( isdigit( *pStr ) )
nSec = nSec * 16 + (*pStr - '0'); nSec = nSec * 16 + (*pStr - '0');
else else
nSec = nSec * 16 + (sal_uInt16)(toupper( *pStr ) - 'A' + 10 ); nSec = nSec * 16 + (sal_uInt16)(rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 );
else else
return false; return false;
pStr++; pStr++;
...@@ -209,7 +210,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr ) ...@@ -209,7 +210,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr )
if( isdigit( *pStr ) ) if( isdigit( *pStr ) )
nThird = nThird * 16 + (*pStr - '0'); nThird = nThird * 16 + (*pStr - '0');
else else
nThird = nThird * 16 + (sal_uInt16)(toupper( *pStr ) - 'A' + 10 ); nThird = nThird * 16 + (sal_uInt16)(rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 );
else else
return false; return false;
pStr++; pStr++;
...@@ -224,7 +225,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr ) ...@@ -224,7 +225,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr )
if( isdigit( *pStr ) ) if( isdigit( *pStr ) )
szRemain[i/2] = szRemain[i/2] * 16 + (*pStr - '0'); szRemain[i/2] = szRemain[i/2] * 16 + (*pStr - '0');
else else
szRemain[i/2] = szRemain[i/2] * 16 + (sal_Int8)(toupper( *pStr ) - 'A' + 10 ); szRemain[i/2] = szRemain[i/2] * 16 + (sal_Int8)(rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 );
else else
return false; return false;
pStr++; pStr++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment