-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Milestone
Description
Describe the bug
When you pass the pattern "^"
or ""
to gsub, it loops forever and eventually runs out of memory.
To Reproduce
$ echo '{"key": "value"}' | jq '.key|=gsub("^";"")'
error: cannot allocate memory
Aborted (core dumped)
$ echo '{"key": "value"}' | jq '.key|=gsub("";"")'
^C
$ echo '{"key": "value"}' | jq '.key|=gsub("^";"new-prefix")'
^C
$
Expected behavior
Once the match has been successful, it shouldn't be tried again for the same location.
Environment (please complete the following information):
$ cat /etc/issue ; jq -V ; echo ; dpkg -s jq | grep -e Version -e Package
Ubuntu 20.04 LTS \n \l
jq-1.6
Package: jq
Version: 1.6-1
$
Additional context
Add any other context about the problem here.
emanuele6, Pwuts, weeble and Fraasi