Fix: (outline-path) Normalizer infinite loop

Hopefully there aren't more of these lurking, but with the recent
--normalize-query change, there might be...
This commit is contained in:
Adam Porter 2021-06-21 07:55:58 -05:00
parent 482a5c939b
commit e03fb24f9b
2 changed files with 8 additions and 1 deletions

View file

@ -1481,6 +1481,7 @@ any link is found."
(match-string org-ql-link-description-group))))))))) (match-string org-ql-link-description-group)))))))))
;; MAYBE: Preambles for outline-path predicates. Not sure if possible without complicated logic. ;; MAYBE: Preambles for outline-path predicates. Not sure if possible without complicated logic.
;; FIXME: These preds say they accept regexps but the strings get regexp-quoted. They should probably just take strings.
(org-ql-defpred (outline-path olp) (&rest regexps) (org-ql-defpred (outline-path olp) (&rest regexps)
"Return non-nil if current node's outline path matches all of REGEXPS. "Return non-nil if current node's outline path matches all of REGEXPS.
@ -1496,7 +1497,7 @@ the following queries:
(olp \"Food\" \"Grapes\")" (olp \"Food\" \"Grapes\")"
:normalizers ((`(,predicate-names . ,strings) :normalizers ((`(,predicate-names . ,strings)
;; Regexp quote headings. ;; Regexp quote headings.
`(outline-path ,@(mapcar #'regexp-quote strings)))) `(org-ql--predicate-outline-path ,@(mapcar #'regexp-quote strings))))
:body (let ((entry-olp (org-ql--value-at (point) #'org-ql--outline-path))) :body (let ((entry-olp (org-ql--value-at (point) #'org-ql--outline-path)))
(cl-loop for h in regexps (cl-loop for h in regexps
always (cl-member h entry-olp :test #'string-match)))) always (cl-member h entry-olp :test #'string-match))))

View file

@ -251,6 +251,12 @@ with keyword arg NOW in PLIST."
:to-equal '(link :description "DESCRIPTION" :target "TARGET" :to-equal '(link :description "DESCRIPTION" :target "TARGET"
:regexp-p t)))) :regexp-p t))))
(describe "(outline-path)"
(it "with a regexp metacharacter"
;; Ensures that normalizer doesn't infinitely loop.
(expect (org-ql--normalize-query '(olp "a." "b"))
:to-equal '(org-ql--predicate-outline-path "a\\." "b"))))
(describe "timestamp predicates" (describe "timestamp predicates"
;; NOTE: (clocked) and (closed) don't accept :with-time arguments. ;; NOTE: (clocked) and (closed) don't accept :with-time arguments.
(describe "(clocked)" (describe "(clocked)"