Skip to content

Commit fd48ac0

Browse files
committed
Fix regression to entity format validation
Since 139908f, HTML entities are not replaced if a colon appears at *any* further position in the document This also tightens up the logic of automatic entity decoding
1 parent d74b7de commit fd48ac0

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/Entities.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ int Entities::decode() {
7979
return result;
8080
}
8181

82-
// Disallow `:` inside entities, and `;` inside emoji
83-
if ((target.find(chInvalid, charIndex) != std::wstring::npos) ||
84-
// Make sure the selection includes the terminating char
85-
(target.find(chEnd, charIndex) == std::wstring::npos)) {
82+
size_t endPos = target.find(chEnd, charIndex);
83+
// Make sure the selection includes the terminating char
84+
if ((endPos == std::wstring::npos) ||
85+
// Disallow `:` inside entities, and `;` inside emoji
86+
(target.find(chInvalid, charIndex) < endPos)) {
8687
return result;
8788
}
8889

src/HtmlTag.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,11 @@ void findAndDecode(const int keyCode, DecodeCmd cmd) {
626626
break;
627627
if (plugin.options.liveEntityDecoding || cmd == dcEntity) {
628628
if (anchor == startPos)
629-
skipEntities = !isEndOfEntity(chCurrent); // No adjacent entity here
629+
skipEntities =
630+
// No adjacent entity here
631+
!isEndOfEntity(chCurrent) ||
632+
// Do nothing if current text is `:;`, `;:`, `;;` or `::`
633+
isEndOfEntity(static_cast<int>(doc.sendMessage(SCI_GETCHARAT, anchor - 1)));
630634
else if (anchor < startPos && !skipEntities && isStartOfEntity(chCurrent)) { // Handle entities
631635
didReplace = replace(Entities::decode, anchor, caret);
632636
if (!(ch == 0x0A || ch == 0x0D))

0 commit comments

Comments
 (0)