mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2025-12-06 06:52:01 +01:00
Html/Markdown: fix-up potential ENTITY_BOUNDS_INVALID
This commit is contained in:
parent
c1a18a63c0
commit
865c841bd6
|
|
@ -234,6 +234,7 @@ namespace TL
|
|||
}
|
||||
if (lastBlockQuote is { length: -1 })
|
||||
lastBlockQuote.length = sb.Length - lastBlockQuote.offset;
|
||||
HtmlText.FixUps(sb, entities);
|
||||
text = sb.ToString();
|
||||
return entities.Count == 0 ? null : [.. entities];
|
||||
}
|
||||
|
|
@ -431,10 +432,22 @@ namespace TL
|
|||
else
|
||||
offset++;
|
||||
}
|
||||
FixUps(sb, entities);
|
||||
text = sb.ToString();
|
||||
return entities.Count == 0 ? null : [.. entities];
|
||||
}
|
||||
|
||||
internal static void FixUps(StringBuilder sb, List<MessageEntity> entities)
|
||||
{
|
||||
int truncate = 0;
|
||||
while (char.IsWhiteSpace(sb[^++truncate]));
|
||||
if (truncate == 1) return;
|
||||
var len = sb.Length -= --truncate;
|
||||
foreach (var entity in entities)
|
||||
if (entity.offset + entity.length > len)
|
||||
entity.length = len - entity.offset;
|
||||
}
|
||||
|
||||
/// <summary>Converts the (plain text + entities) format used by Telegram messages into an <a href="https://core.telegram.org/bots/api/#html-style">HTML-formatted text</a></summary>
|
||||
/// <param name="client">Client, used only for getting current user ID in case of <c>InputMessageEntityMentionName+InputUserSelf</c></param>
|
||||
/// <param name="message">The plain text, typically obtained from <see cref="Message.message"/></param>
|
||||
|
|
|
|||
|
|
@ -4079,15 +4079,25 @@ namespace TL
|
|||
public Messages_StickerSet stickerset;
|
||||
}
|
||||
/// <summary>The order of stickersets was changed <para>See <a href="https://corefork.telegram.org/constructor/updateStickerSetsOrder"/></para></summary>
|
||||
[TLDef(0x0BB2D201, inheritBefore = true)]
|
||||
public sealed partial class UpdateStickerSetsOrder : UpdateStickerSets
|
||||
[TLDef(0x0BB2D201)]
|
||||
public sealed partial class UpdateStickerSetsOrder : Update
|
||||
{
|
||||
/// <summary>Extra bits of information, use <c>flags.HasFlag(...)</c> to test for those</summary>
|
||||
public Flags flags;
|
||||
/// <summary>New sticker order by sticker ID</summary>
|
||||
public long[] order;
|
||||
|
||||
[Flags] public enum Flags : uint
|
||||
{
|
||||
/// <summary>Whether the updated stickers are mask stickers</summary>
|
||||
masks = 0x1,
|
||||
/// <summary>Whether the updated stickers are custom emoji stickers</summary>
|
||||
emojis = 0x2,
|
||||
}
|
||||
}
|
||||
/// <summary>Installed stickersets have changed, the client should refetch them as <a href="https://corefork.telegram.org/api/stickers#installing-stickersets">described in the docs</a>. <para>See <a href="https://corefork.telegram.org/constructor/updateStickerSets"/></para></summary>
|
||||
[TLDef(0x31C24808)]
|
||||
public partial class UpdateStickerSets : Update
|
||||
public sealed partial class UpdateStickerSets : Update
|
||||
{
|
||||
/// <summary>Extra bits of information, use <c>flags.HasFlag(...)</c> to test for those</summary>
|
||||
public Flags flags;
|
||||
|
|
|
|||
Loading…
Reference in a new issue