[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dape 35d55de0c5 090/123: Improve robustness of DAP pars
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dape 35d55de0c5 090/123: Improve robustness of DAP parsing |
Date: |
Tue, 5 Dec 2023 03:58:03 -0500 (EST) |
branch: externals/dape
commit 35d55de0c54ed69c436e1d2b086f784d11fbe8bb
Author: Daniel Pettersson <daniel@dpettersson.net>
Commit: Daniel Pettersson <daniel@dpettersson.net>
Improve robustness of DAP parsing
---
dape.el | 40 +++++++++++++++++++---------------------
1 file changed, 19 insertions(+), 21 deletions(-)
diff --git a/dape.el b/dape.el
index 87844bf83e..30f629cd1e 100644
--- a/dape.el
+++ b/dape.el
@@ -521,8 +521,7 @@ On SKIP-PROCESS-BUFFERS skip deletion of buffers which has
processes."
;; Some adapters can't help them self, sending headers not in spec..
(defconst dape--content-length-re
- "\\(?:.*: .*\r?\n\\)*\
-Content-Length: \\([[:digit:]]+\\)\r?\n\
+ "Content-Length: \\([[:digit:]]+\\)\r?\n\
\\(?:.*: .*\r?\n\\)*\
\r?\n"
"Matches debug adapter protocol header.")
@@ -613,15 +612,16 @@ If NOWARN does not error on no active process."
(goto-char (point-max))
(insert string)
(goto-char (point-min))
- (let (done start)
- (while (and (not done)
- (setq start (point))
+ (let (expecting-more-bytes start)
+ (while (and (setq start (point))
+ (search-forward "Content-Length: " nil t)
+ (goto-char (match-beginning 0))
(search-forward-regexp dape--content-length-re
- nil t))
- ;; Server garbage?
+ (+ (point) 1000) t))
+ ;; Server non dap output?
(unless (equal start (match-beginning 0))
- (let ((std-out (buffer-substring (point-min) (match-beginning 0))))
- (dape--debug 'std-server "%s" std-out)))
+ (dape--debug 'std-server "%s"
+ (buffer-substring start (match-beginning 0))))
(let ((content-length (string-to-number (match-string 1))))
(if-let* ((expected-end
(byte-to-position
@@ -633,19 +633,17 @@ If NOWARN does not error on no active process."
:false-object nil)
(error
(and
- (let ((json-str (buffer-substring (point)
expected-end)))
- (dape--debug 'error
- "Failed to parse json from `%s`"
- json-str))
+ (dape--debug 'error
+ "Failed to parse json from `%s`"
+ (buffer-substring (point)
expected-end))
nil)))))
- (with-current-buffer buffer
- (dape--handle-object process object))
- ;; Do we have some garbage input?
- (if (search-forward-regexp "Content-Length: [[:digit:]]+\r?\n"
- nil t)
- (goto-char (match-beginning 0))
- (goto-char start)
- (setq done t))))))
+ (with-current-buffer buffer
+ (setq expecting-more-bytes nil)
+ (dape--handle-object process object))
+ (dape--debug 'info "Need more bytes")
+ (setq expecting-more-bytes t))))
+ (when expecting-more-bytes
+ (goto-char (point-min))))
;; This seams like we are living a bit dangerous. If input buffer
;; is killed we are going to erase some random buffer
(when (buffer-live-p input-buffer)
- [elpa] externals/dape 3149577a9e 083/123: Use dape--repl-prompt var, (continued)
- [elpa] externals/dape 3149577a9e 083/123: Use dape--repl-prompt var, ELPA Syncer, 2023/12/05
- [elpa] externals/dape e34a87dd67 097/123: Handle capabilities event, ELPA Syncer, 2023/12/05
- [elpa] externals/dape ca555bcba3 112/123: UI rewrite, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 20105f5b47 121/123: Harden dape-kill action as per specification, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 94b99c3a5b 066/123: Fix wrong error for step-like functions when no stopped threads, ELPA Syncer, 2023/12/05
- [elpa] externals/dape b501759e89 072/123: Change default for `dape-repl-use-shorthand', ELPA Syncer, 2023/12/05
- [elpa] externals/dape 6ec0bfbcf2 079/123: Remove busy wait from dape-kill, ELPA Syncer, 2023/12/05
- [elpa] externals/dape ff3037cb58 081/123: Use same buffer strategy on dape-quit-disconnect, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 9be8f20685 084/123: Fix zombied REPL dummy processes, ELPA Syncer, 2023/12/05
- [elpa] externals/dape bb54d57fc6 088/123: Change dape--debug to macro to remove arg evaluation, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 35d55de0c5 090/123: Improve robustness of DAP parsing,
ELPA Syncer <=
- [elpa] externals/dape f40d7932cc 093/123: Print both description and text from stopped event, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 6b4cebae5f 098/123: Use own keymap for dape--config-read, ELPA Syncer, 2023/12/05
- [elpa] externals/dape ff3a27dbbd 099/123: Fix a typo, ELPA Syncer, 2023/12/05
- [elpa] externals/dape ee2ecae446 122/123: Bump version and add FSF copyright line, ELPA Syncer, 2023/12/05
- [elpa] externals/dape b52882f627 123/123: Fix dape-key-prefix type #28, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 5499b7d3d1 114/123: Add fringe breakpoint icon, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 2e8202ad9a 006/123: Small doc fixups, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 73150fca55 063/123: Add paging to dape info variables to reduce UI locking, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 1bef80cf37 068/123: Remove confusing default for dape-main-functions, ELPA Syncer, 2023/12/05
- [elpa] externals/dape 2a4462d36a 073/123: Fix nil-ed plist props in config diff, ELPA Syncer, 2023/12/05