XEP-0461: fix char counting

I think this time I got it right, confirmed
against client implementations (dino and movim)
This commit is contained in:
nicoco 2023-02-24 00:11:06 +01:00
parent 79ffa1668f
commit 40a857de65
2 changed files with 4 additions and 4 deletions

View file

@ -24,7 +24,7 @@ class FeatureFallBack(ElementBase):
end = self["fallback_body"]["end"] end = self["fallback_body"]["end"]
body = self.parent()["body"] body = self.parent()["body"]
if start <= end: if start <= end:
return body[start:end+1] return body[start:end]
else: else:
return "" return ""
@ -44,7 +44,7 @@ class FeatureFallBack(ElementBase):
msg["body"] = quoted + msg["body"] msg["body"] = quoted + msg["body"]
msg["feature_fallback"]["for"] = NS msg["feature_fallback"]["for"] = NS
msg["feature_fallback"]["fallback_body"]["start"] = 0 msg["feature_fallback"]["fallback_body"]["start"] = 0
msg["feature_fallback"]["fallback_body"]["end"] = len(quoted) - 1 msg["feature_fallback"]["fallback_body"]["end"] = len(quoted)
class FallBackBody(ElementBase): class FallBackBody(ElementBase):

View file

@ -54,8 +54,8 @@ class TestReply(SlixTest):
""" """
<message xmlns="jabber:client" type="normal"> <message xmlns="jabber:client" type="normal">
<body>> Anna wrote:\n> Hi, how are you?\nGreat</body> <body>> Anna wrote:\n> Hi, how are you?\nGreat</body>
<fallback xmlns="urn:xmpp:feature-fallback:0" for="urn:xmpp:reply:0"> <fallback xmlns="urn:xmpp:fallback:0" for="urn:xmpp:reply:0">
<body start='0' end='32' /> <body start='0' end='33' />
</fallback> </fallback>
</message> </message>
""" """