|
From: Adam S. <as...@ko...> - 2019-07-29 14:48:35
|
This because at least ejabberd 18.12.1 (as packaged in Debian
10 (buster)) sends 6 digits in delay timestamps, e.g.:
"2019-07-29T14:04:41.392002Z"
which would result in the error
Args out of range: "002Z", 4, 6
and the delayed messages would not show up at all.
With this fix jabber-parse-time returns (23870 64761) as expected.
---
Hi,
I lost messages due to this, please consider including this fix (or
something to the same effect) in jabber.el!
Best regards,
Adam
jabber-util.el | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/jabber-util.el b/jabber-util.el
index c089dcf..74d4538 100644
--- a/jabber-util.el
+++ b/jabber-util.el
@@ -488,8 +488,8 @@ TIME is in a format accepted by `format-time-string'."
(second (string-to-number (substring time 17 19)))
;; fractions are optional
(fraction (if (eq (aref time 19) ?.)
- (string-to-number (substring time 20 23))))
- (timezone (substring time (if fraction 23 19))))
+ (string-to-number (substring time 20 (jabber-end-of-digits time 20)))))
+ (timezone (substring time (if fraction (jabber-end-of-digits time 20) 19))))
;; timezone is either Z (UTC) or [+-]HH:MM
(let ((timezone-seconds
(if (string= timezone "Z")
@@ -499,6 +499,13 @@ TIME is in a format accepted by `format-time-string'."
(string-to-number (substring timezone 4 6))))))))
(encode-time second minute hour day month year timezone-seconds))))
+(defun jabber-end-of-digits (time pos)
+ "Return the first position after pos in time, that is not a
+digit. This is because the fraction of seconds doesn't
+necessarily have 3 digits, it might be more (like 6)."
+ (let ((subtime (substring time pos)))
+ (+ pos (string-match "[^0-9]" subtime))))
+
(defun jabber-report-success (jc xml-data context)
"IQ callback reporting success or failure of the operation.
CONTEXT is a string describing the action.
--
2.22.0
--
"There are forty people in the world and five of them Adam Sjøgren
are hamburgers." as...@ko...
|