Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/sentry/interfaces/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
from django.utils.translation import gettext as _

from sentry.interfaces.base import Interface
from sentry.utils import json
from sentry.utils.json import prune_empty_keys
from sentry.utils.safe import get_path, safe_urlencode
from sentry.utils.strings import to_unicode
from sentry.web.helpers import render_to_string


Expand Down Expand Up @@ -63,10 +61,6 @@ def fix_broken_encoding(value):
return value


def jsonify(value):
return to_unicode(value) if isinstance(value, str) else json.dumps(value)


class Http(Interface):
"""
The Request information is stored in the Http interface. Two arguments
Expand Down
19 changes: 1 addition & 18 deletions src/sentry/templatetags/sentry_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@
from django import template
from django.template.defaultfilters import stringfilter
from django.utils import timezone as django_timezone
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.utils.translation import gettext as _
from packaging.version import parse as parse_version

from sentry import options
from sentry.api.serializers import serialize as serialize_func
from sentry.utils import json
from sentry.utils.strings import soft_break as _soft_break
from sentry.utils.strings import soft_hyphenate, to_unicode, truncatechars
from sentry.utils.strings import soft_hyphenate, truncatechars

SentryVersion = namedtuple("SentryVersion", ["current", "latest", "update_available", "build"])

Expand Down Expand Up @@ -139,21 +137,6 @@ def security_contact():
return options.get("system.security-email") or options.get("system.admin-email")


@register.filter
def pprint(value, break_after=10):
"""
break_after is used to define how often a <span> is
inserted (for soft wrapping).
"""

value = to_unicode(value)
return mark_safe(
"<span></span>".join(
escape(value[i : (i + break_after)]) for i in range(0, len(value), break_after)
)
)


@register.filter
def is_url(value):
if not isinstance(value, str):
Expand Down
17 changes: 2 additions & 15 deletions src/sentry/utils/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import string
import zlib
from collections.abc import Callable
from typing import Any, overload
from typing import overload

from django.utils.encoding import force_str, smart_str
from django.utils.encoding import smart_str

_sprintf_placeholder_re = re.compile(
r"%(?:\d+\$)?[+-]?(?:[ 0]|\'.{1})?-?\d*(?:\.\d+)?[bcdeEufFgGosxX]"
Expand Down Expand Up @@ -116,19 +116,6 @@ def soft_break_delimiter(match: re.Match[str]) -> str:
return re.sub(rf"\S{{{length},}}", soft_break_delimiter, value)


def to_unicode(value: Any) -> str:
try:
value = str(force_str(value))
except (UnicodeEncodeError, UnicodeDecodeError):
value = "(Error decoding value)"
except Exception: # in some cases we get a different exception
try:
value = str(repr(type(value)))
except Exception:
value = "(Error decoding value)"
return value


valid_dot_atom_characters = frozenset(string.ascii_letters + string.digits + ".!#$%&'*+-/=?^_`{|}~")


Expand Down