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