Revert "Bug 1968267: Ignore 0x0 0xa combination at end of clipboard text r=win-reviewers,gstoll a=RyanVM" as part of reverting Bug 1966443
This reverts commit 140ce197d1.
This commit is contained in:
committed by
dmeehan@mozilla.com
parent
4c02d92b62
commit
62baff5750
@@ -710,28 +710,17 @@ HRESULT nsClipboard::FillSTGMedium(IDataObject* aDataObject, UINT aFormat,
|
|||||||
// since Windows also appears to add null termination. See GetGlobalData.
|
// since Windows also appears to add null termination. See GetGlobalData.
|
||||||
template <typename CharType>
|
template <typename CharType>
|
||||||
static nsresult GetCharDataFromGlobalData(STGMEDIUM& aStm, CharType** aData,
|
static nsresult GetCharDataFromGlobalData(STGMEDIUM& aStm, CharType** aData,
|
||||||
uint32_t* aByteLen) {
|
uint32_t* aLen) {
|
||||||
uint32_t nBytes = 0;
|
uint32_t nBytes = 0;
|
||||||
MOZ_TRY(nsClipboard::GetGlobalData(aStm.hGlobal,
|
MOZ_TRY(nsClipboard::GetGlobalData(aStm.hGlobal,
|
||||||
reinterpret_cast<void**>(aData), &nBytes));
|
reinterpret_cast<void**>(aData), &nBytes));
|
||||||
auto nChars = nBytes / sizeof(CharType);
|
auto nChars = nBytes / sizeof(CharType);
|
||||||
if (nChars < 1) {
|
if (nChars < 1) {
|
||||||
*aByteLen = 0;
|
*aLen = 0;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
bool hasNullTerminator = (*aData)[nChars - 1] == CharType(0);
|
||||||
const CharType* data = *aData;
|
*aLen = hasNullTerminator ? nBytes - sizeof(CharType) : nBytes;
|
||||||
if (nChars > 1 && data[nChars - 2] == CharType(0x00) &&
|
|
||||||
data[nChars - 1] == CharType(0x0a)) {
|
|
||||||
// The char array ends in the nonsense combination null + LF. Remove both.
|
|
||||||
// Word sometimes does this.
|
|
||||||
nChars -= 2;
|
|
||||||
} else if (data[nChars - 1] == CharType(0)) {
|
|
||||||
// Remove null termination.
|
|
||||||
nChars -= 1;
|
|
||||||
}
|
|
||||||
*aByteLen = nChars * sizeof(CharType);
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user