mirror of
https://github.com/ditkrg/todo-to-issue-action.git
synced 2026-01-22 22:06:43 +00:00
fix: escape title when searching for comment line
If regex characters are part of the title (for example, parentheses), then this breaks the ability to find the comment line when trying to insert the issue URL. This commit escapes the title to fix this problem. Closes github.com/alstr/todo-to-issue-action#226
This commit is contained in:
parent
f752af8130
commit
b4b115f060
2
main.py
2
main.py
@ -76,7 +76,7 @@ def process_diff(diff, client=Client(), insert_issue_urls=False, parser=TodoPars
|
||||
if line_number < len(file_lines):
|
||||
# Duplicate the line to retain the comment syntax.
|
||||
old_line = file_lines[line_number]
|
||||
remove = fr'(?i:{raw_issue.identifier}).*{raw_issue.title}'
|
||||
remove = fr'(?i:{raw_issue.identifier}).*{re.escape(raw_issue.title)}'
|
||||
insert = f'Issue URL: {client.get_issue_url(new_issue_number)}'
|
||||
new_line = re.sub(remove, insert, old_line)
|
||||
# make sure the above operation worked as intended
|
||||
|
||||
Loading…
Reference in New Issue
Block a user