Skip to content

Commit

Permalink
Better Fix for Zalgo/RTL.
Browse files Browse the repository at this point in the history
Moved the check into src/Utilities/functions so it can be accessed by both BattleManager and Teambuilder when needed.
  • Loading branch information
Benjamin Lee committed Jan 11, 2012
1 parent c5c9675 commit 823dd72
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 79 deletions.
14 changes: 2 additions & 12 deletions src/BattleManager/BattleManager.pro
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ SOURCES += \
auxpokedataproxy.cpp \
proxydatacontainer.cpp \
datacontainer.cpp \
regularbattlescene.cpp \
remove_troll_characters.cpp
regularbattlescene.cpp

HEADERS +=\
command.h \
Expand Down Expand Up @@ -60,8 +59,7 @@ HEADERS +=\
battlesceneflow.h \
param.h \
regularbattlescene.h \
../Shared/battlecommands.h \
remove_troll_characters.h
../Shared/battlecommands.h

QMAKE_CXXFLAGS += "-std=c++0x -U__STRICT_ANSI__"

Expand Down Expand Up @@ -125,11 +123,3 @@ OTHER_FILES += \
../../bin/qml/BattleDataQML/Moves/BoneRush.qml

include(../Shared/Common.pri)








2 changes: 1 addition & 1 deletion src/BattleManager/battleclientlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "battledata.h"
#include "teamdata.h"
#include "defaulttheme.h"
#include "remove_troll_characters.h"
#include "../Utilities/functions.h"

typedef ShallowBattlePoke* shallowpoke;
typedef BattleData<DataContainer> battledata;
Expand Down
19 changes: 0 additions & 19 deletions src/BattleManager/remove_troll_characters.cpp

This file was deleted.

9 changes: 0 additions & 9 deletions src/BattleManager/remove_troll_characters.h

This file was deleted.

10 changes: 2 additions & 8 deletions src/Teambuilder/Teambuilder.pro
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ SOURCES += main.cpp \
poketextedit.cpp \
password_wallet.cpp\
spectatorwindow.cpp \
replayviewer.cpp \
remove_troll_characters.cpp
replayviewer.cpp
HEADERS += ../PokemonInfo/pokemoninfo.h \
menu.h \
mainwindow.h \
Expand Down Expand Up @@ -103,8 +102,7 @@ HEADERS += ../PokemonInfo/pokemoninfo.h \
../BattleManager/battleclientlog.h \
basebattlewindowinterface.h \
themeaccessor.h \
replayviewer.h \
remove_troll_characters.h
replayviewer.h
LIBS += -L../../bin \
-lpokemonlib \
-lutilities \
Expand Down Expand Up @@ -148,7 +146,3 @@ CONFIG(debian) {
CONFIG(popmsyoustartonly):DEFINES += PO_PMS_YOU_START_ONLY

include(../Shared/Common.pri)




2 changes: 1 addition & 1 deletion src/Teambuilder/channel.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "channel.h"
#include "client.h"
#include "poketextedit.h"
#include "remove_troll_characters.h"
#include "../Utilities/functions.h"
#include "theme.h"

Channel::Channel(const QString &name, int id, Client *parent)
Expand Down
2 changes: 1 addition & 1 deletion src/Teambuilder/pmwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "pmwindow.h"
#include "../Utilities/otherwidgets.h"
#include "remove_troll_characters.h"
#include "../Utilities/functions.h"

PMWindow::PMWindow(int id, const QString &ownName, const QString &name, const QString &content, bool html, bool pmDisabled, int starterAuth)
: m_ownName(ownName), escape_html(!html)
Expand Down
19 changes: 0 additions & 19 deletions src/Teambuilder/remove_troll_characters.cpp

This file was deleted.

9 changes: 0 additions & 9 deletions src/Teambuilder/remove_troll_characters.h

This file was deleted.

18 changes: 18 additions & 0 deletions src/Utilities/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ QString cleanStringForFiles(const QString &title)
return ret;
}

QString removeTrollCharacters(const QString& s)
{
// All Non-Spacing Mark characters are banned and will trigger this filter.
QString result = s;
QChar const rtloverride(0x202e);
for (int x = 0;x<result.size();x++) {
if ((result.at(x)).category() == QChar::Mark_NonSpacing) {
result.replace(result.at(x), "");
x = 0;
}
}
// Removes RTL override
if (result.contains(rtloverride)) {
result.replace(rtloverride, "");
}
return result;
}

void writeSettings(QWidget *w)
{
QSettings settings;
Expand Down
2 changes: 2 additions & 0 deletions src/Utilities/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ inline QString toBoldColor(const QString &mess, const QColor &col)

QString cleanStringForFiles(const QString &title);

QString removeTrollCharacters(const QString& s);

inline long int true_rand() {
return (rand() + unsigned(clock()))%RAND_MAX;
}
Expand Down

0 comments on commit 823dd72

Please sign in to comment.