diff options
author | George Hazan <george.hazan@gmail.com> | 2024-10-21 21:23:21 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-10-21 21:23:21 +0300 |
commit | 792207209ade53f715684de34f61029dd9752f06 (patch) | |
tree | eeb3fc2924bd2a610147efa5560064415bca55a8 | |
parent | 2d3a404b24f0b3de8c5d759cb175cc36f6789733 (diff) |
fixes #4625 (Skypeweb+NS: окультурить внешний вид цитат)
-rw-r--r-- | protocols/SkypeWeb/src/skype_utils.cpp | 56 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/stdafx.h | 1 |
2 files changed, 44 insertions, 13 deletions
diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp index 06b2706f41..57b22cde4f 100644 --- a/protocols/SkypeWeb/src/skype_utils.cpp +++ b/protocols/SkypeWeb/src/skype_utils.cpp @@ -344,6 +344,19 @@ const HtmlEntity htmlEntities[] = { "zwnj", "\xE2\x80\x8C" }
};
+static CMStringW getAttrText(const wchar_t *pwszText, const wchar_t *pwszAttrName)
+{
+ if (auto *p1 = mir_wstrstri(pwszText, pwszAttrName)) {
+ p1 += wcslen(pwszAttrName);
+ if (p1[0] == '=' && p1[1] == '\"') {
+ p1 += 2;
+ if (auto *p2 = wcschr(p1, '\"'))
+ return CMStringW(p1, p2 - p1);
+ }
+ }
+ return L"";
+}
+
CMStringW CSkypeProto::RemoveHtml(const CMStringW &data, bool bCheckSS)
{
bool inSS = false;
@@ -362,22 +375,39 @@ CMStringW CSkypeProto::RemoveHtml(const CMStringW &data, bool bCheckSS) }
else if (m_bUseBBCodes) {
bool bEnable = true;
- if (data[i + 1] == '/') {
- i++;
+ auto *p = data.c_str() + i + 1;
+ if (*p == '/') {
bEnable = false;
+ p++;
}
- switch (data[i + 1]) {
- case 'b': new_string.Append(bEnable ? L"[b]" : L"[/b]"); break;
- case 'i': new_string.Append(bEnable ? L"[i]" : L"[/i]"); break;
- case 'u': new_string.Append(bEnable ? L"[u]" : L"[/u]"); break;
- case 's': new_string.Append(bEnable ? L"[s]" : L"[/s]"); break;
- default:
- if (!wcsncmp(data.c_str() + i + 1, L"pre ", 4))
- new_string.Append(L"[code]");
- else if (!wcsncmp(data.c_str() + i + 1, L"pre>", 4))
- new_string.Append(L"[/code]");
- break;
+ if (!wcsncmp(p, L"b>", 2))
+ new_string.Append(bEnable ? L"[b]" : L"[/b]");
+ else if (!wcsncmp(p, L"i>", 2))
+ new_string.Append(bEnable ? L"[i]" : L"[/i]");
+ else if (!wcsncmp(p, L"u>", 2))
+ new_string.Append(bEnable ? L"[u]" : L"[/u]");
+ else if (!wcsncmp(p, L"s>", 2))
+ new_string.Append(bEnable ? L"[s]" : L"[/s]");
+ else if (!wcsncmp(p, L"pre ", 4))
+ new_string.Append(L"[code]");
+ else if (!wcsncmp(p, L"pre>", 4))
+ new_string.Append(L"[/code]");
+ else if (!wcsncmp(p, L"legacyquote>", 12)) {
+ if (bEnable)
+ i = data.Find(L"legacyquote>", i+13);
+ }
+ else if (!wcsncmp(p, L"quote ", 6)) {
+ CMStringW author(getAttrText(p, L"authorname"));
+ CMStringW timestamp(getAttrText(p, L"timestamp"));
+
+ wchar_t wszTime[100];
+ TimeZone_PrintTimeStamp(0, _wtoi(timestamp), L"D t", wszTime, _countof(wszTime), 0);
+
+ new_string.AppendFormat(L"[quote]%s %s %s: \r\n", wszTime, author.c_str(), TranslateT("wrote"));
+ }
+ else if (!wcsncmp(p, L"quote>", 6)) {
+ new_string.Append(L"[/quote]");
}
}
diff --git a/protocols/SkypeWeb/src/stdafx.h b/protocols/SkypeWeb/src/stdafx.h index 645dfd4bb2..5120fb3c46 100644 --- a/protocols/SkypeWeb/src/stdafx.h +++ b/protocols/SkypeWeb/src/stdafx.h @@ -42,6 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <m_popup.h>
#include <m_icolib.h>
#include <m_userinfo.h>
+#include <m_timezones.h>
#include <m_contacts.h>
#include <m_message.h>
#include <m_avatars.h>
|