branch: externals/yaml commit a2ed8f1fd6f03adb79b909e4a776581f3ecf897a Author: Zachary Romero <zacrom...@posteo.net> Commit: Zachary Romero <zacrom...@posteo.net>
Fix empty single quote string bug --- yaml-tests.el | 5 ++++- yaml.el | 16 +++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/yaml-tests.el b/yaml-tests.el index 928d18638b..7a3aae569e 100644 --- a/yaml-tests.el +++ b/yaml-tests.el @@ -341,7 +341,10 @@ key-2: |2- :object-key-type 'string :object-type 'alist) '(("key-1" . " ---\n ---") - ("key-2" . " ---\n ---"))))) + ("key-2" . " ---\n ---")))) + (should (equal (yaml-parse-string "''") "")) + (should (equal (yaml-parse-string "foo: ''" :object-type 'alist) + '((foo . ""))))) (ert-deftest yaml-parsing-completes () diff --git a/yaml.el b/yaml.el index f7c7ee02b2..5a21f28cb3 100644 --- a/yaml.el +++ b/yaml.el @@ -581,13 +581,15 @@ reverse order." (substring x 1) " ")) replaced)) - (replaced (replace-regexp-in-string - "''" - (lambda (x) - (if (> (length x) 1) - (substring x 1) - "'")) - replaced))) + (replaced (if (not (equal "''" replaced)) + (replace-regexp-in-string + "''" + (lambda (x) + (if (> (length x) 1) + (substring x 1) + "'")) + replaced) + replaced))) (yaml--scalar-event "single" (substring replaced 1 (1- (length replaced))))))) ("c-double-quoted" .