Fixed #6839 Wrong text encoding in iMessage (#6927)

* Fixed #6839 Wrong text encoding in iMessage

* Update ChangeLog
This commit is contained in:
SerhiiGadzhilov 2021-01-27 21:38:52 +02:00 committed by GitHub
parent 70d67040b7
commit 7128f8f5f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 97 additions and 11 deletions

View file

@ -8,6 +8,7 @@ Bug fixes:
- #6920 Windows Installer checksums
- #6921 Handling pre-main window creation status notifications
- #6922 macOS CI build
- #6927 Text copied and pasted between Windows and Mac OS converts to japanese
Enhancements:
- #6912 Removes UI for Screen Saver Sync and Files Drag and Drop

View file

@ -19,6 +19,7 @@
#include "platform/OSXClipboard.h"
#include "synergy/Clipboard.h"
#include "platform/OSXClipboardUTF8Converter.h"
#include "platform/OSXClipboardUTF16Converter.h"
#include "platform/OSXClipboardTextConverter.h"
#include "platform/OSXClipboardBMPConverter.h"
@ -36,11 +37,10 @@ OSXClipboard::OSXClipboard() :
{
m_converters.push_back(new OSXClipboardHTMLConverter);
m_converters.push_back(new OSXClipboardBMPConverter);
m_converters.push_back(new OSXClipboardUTF8Converter);
m_converters.push_back(new OSXClipboardUTF16Converter);
m_converters.push_back(new OSXClipboardTextConverter);
OSStatus createErr = PasteboardCreate(kPasteboardClipboard, &m_pboard);
if (createErr != noErr) {
LOG((CLOG_DEBUG "failed to create clipboard reference: error %i", createErr));
@ -121,16 +121,18 @@ OSXClipboard::add(EFormat format, const String & data)
CFDataRef dataRef = CFDataCreate(kCFAllocatorDefault, (UInt8 *)osXData.data(), osXData.size());
PasteboardItemID itemID = 0;
PasteboardPutItemFlavor(
m_pboard,
itemID,
flavorType,
dataRef,
kPasteboardFlavorNoFlags);
LOG((CLOG_DEBUG "added %d bytes to clipboard format: %d", data.size(), format));
if (dataRef) {
PasteboardPutItemFlavor(
m_pboard,
itemID,
flavorType,
dataRef,
kPasteboardFlavorNoFlags);
CFRelease(dataRef);
LOG((CLOG_DEBUG "added %d bytes to clipboard format: %d", data.size(), format));
}
}
}
}

View file

@ -0,0 +1,19 @@
#include "OSXClipboardUTF8Converter.h"
CFStringRef
OSXClipboardUTF8Converter::getOSXFormat() const
{
return CFSTR("public.utf8-plain-text");
}
String
OSXClipboardUTF8Converter::doFromIClipboard(const String& data) const
{
return data;
}
String
OSXClipboardUTF8Converter::doToIClipboard(const String& data) const
{
return data;
}

View file

@ -0,0 +1,30 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/OSXClipboardAnyTextConverter.h"
class OSXClipboardUTF8Converter : public OSXClipboardAnyTextConverter
{
public:
virtual CFStringRef getOSXFormat() const;
private:
virtual String doFromIClipboard(const String&) const;
virtual String doToIClipboard(const String&) const;
};

View file

@ -0,0 +1,34 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2011 Nick Bolton
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "platform/OSXClipboardUTF8Converter.h"
#include "test/global/gtest.h"
TEST(OSXClipboardUTF8ConverterTests, test_Format)
{
OSXClipboardUTF8Converter converter;
EXPECT_EQ(IClipboard::kText, converter.getFormat());
EXPECT_EQ(CFSTR("public.utf8-plain-text"), converter.getOSXFormat());
}
TEST(OSXClipboardUTF8ConverterTests, test_readWriteClipboard)
{
OSXClipboardUTF8Converter converter;
EXPECT_EQ("test data\r", converter.fromIClipboard("test data\n"));
EXPECT_EQ("test data\n", converter.toIClipboard("test data\r"));
}