fix: parse irc tags with consecutive escapes (#3711)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
Sidd 2022-05-07 06:57:46 -07:00 committed by GitHub
parent 846ffbb422
commit b2ed4c0843
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 1 deletions

View file

@ -10,6 +10,7 @@
- Minor: Added chatter count for each category in viewer list. (#3683) - Minor: Added chatter count for each category in viewer list. (#3683)
- Minor: Sorted usernames in /vips message to be case-insensitive. (#3696) - Minor: Sorted usernames in /vips message to be case-insensitive. (#3696)
- Minor: Added option to open a user's chat in a new tab from the usercard profile picture context menu. (#3625) - Minor: Added option to open a user's chat in a new tab from the usercard profile picture context menu. (#3625)
- Minor: Fixed tag parsing for consecutive escaped characters. (#3711)
- Bugfix: Fixed live notifications for usernames containing uppercase characters. (#3646) - Bugfix: Fixed live notifications for usernames containing uppercase characters. (#3646)
- Bugfix: Fixed live notifications not getting updated for closed streams going offline. (#3678) - Bugfix: Fixed live notifications not getting updated for closed streams going offline. (#3678)
- Bugfix: Fixed certain settings dialogs appearing behind the main window, when `Always on top` was used. (#3679) - Bugfix: Fixed certain settings dialogs appearing behind the main window, when `Always on top` was used. (#3679)

View file

@ -51,7 +51,6 @@ inline QString parseTagString(const QString &input)
break; break;
} }
i++;
length--; length--;
} }
} }

View file

@ -15,6 +15,7 @@ set(test_SOURCES
${CMAKE_CURRENT_LIST_DIR}/src/RatelimitBucket.cpp ${CMAKE_CURRENT_LIST_DIR}/src/RatelimitBucket.cpp
${CMAKE_CURRENT_LIST_DIR}/src/Hotkeys.cpp ${CMAKE_CURRENT_LIST_DIR}/src/Hotkeys.cpp
${CMAKE_CURRENT_LIST_DIR}/src/UtilTwitch.cpp ${CMAKE_CURRENT_LIST_DIR}/src/UtilTwitch.cpp
${CMAKE_CURRENT_LIST_DIR}/src/IrcHelpers.cpp
# Add your new file above this line! # Add your new file above this line!
) )

61
tests/src/IrcHelpers.cpp Normal file
View file

@ -0,0 +1,61 @@
#include "util/IrcHelpers.hpp"
#include <gtest/gtest.h>
#include <QApplication>
#include <QDebug>
#include <QtConcurrent>
#include <chrono>
#include <thread>
using namespace chatterino;
TEST(IrcHelpers, ParseTagString)
{
struct TestCase {
QString input;
QString expected;
};
std::vector<TestCase> tests{
{
// No space escapes (normal string)
R"(DefectiveCloak gifted a Tier 1 sub to aliiscrying!)",
"DefectiveCloak gifted a Tier 1 sub to aliiscrying!",
},
{
// space at end
R"(DefectiveCloak\s\sgifted\sa\sTier\s1\ssub\sto\s)",
"DefectiveCloak gifted a Tier 1 sub to ",
},
{
// consecutive spaces
R"(DefectiveCloak\s\sgifted\sa\sTier\s1\ssub\sto\saliiscrying!)",
"DefectiveCloak gifted a Tier 1 sub to aliiscrying!",
},
{
// non-consecutive spaces
R"(DefectiveCloak\sgifted\sa\sTier\s1\ssub\sto\saliiscrying!)",
"DefectiveCloak gifted a Tier 1 sub to aliiscrying!",
},
{
// colon to semicolon
R"(foo\:bar)",
"foo;bar",
},
{
// backslash
R"(foo\\bar)",
R"(foo\bar)",
},
};
for (const auto &[input, expected] : tests)
{
const auto actual = parseTagString(input);
EXPECT_EQ(actual, expected)
<< qUtf8Printable(actual) << " (" << qUtf8Printable(input)
<< ") did not match expected value " << qUtf8Printable(expected);
}
}