Skip to content

Commit

Permalink
preserve newlines and tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1te909 committed Jul 30, 2024
1 parent ac3fb03 commit 511bca9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/tacticalrmm/core/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import re
import subprocess
import tempfile
import time
Expand All @@ -16,6 +17,7 @@
from django.http import FileResponse
from meshctrl.utils import get_auth_token
from requests.utils import requote_uri

from tacticalrmm.constants import (
AGENT_TBL_PEND_ACTION_CNT_CACHE_PREFIX,
CORESETTINGS_CACHE_KEY,
Expand Down Expand Up @@ -239,7 +241,8 @@ def _run_url_rest_action(*, url: str, method, body: str, headers: str, instance=
new_url = requote_uri(new_url)

# usually for stderr fields that contain windows file paths, like {{alert.get_result.stderr}}
new_body = new_body.replace("\\", "\\\\")
# but preserves newlines or tabs
new_body = re.sub(r"(?<!\\)(\\)(?![\\nrt])", r"\\\\", new_body)

try:
new_body = json.loads(new_body, strict=False)
Expand Down

0 comments on commit 511bca9

Please sign in to comment.