Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

NewPublisher: Python 2 compatible html escape #3559

Merged
merged 2 commits into from
Jul 26, 2022
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
4 changes: 2 additions & 2 deletions openpype/tools/publisher/publish_report_viewer/model.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import uuid
import html
from Qt import QtCore, QtGui

import pyblish.api

from openpype.tools.utils.lib import html_escape
from .constants import (
ITEM_ID_ROLE,
ITEM_IS_GROUP_ROLE,
Expand Down Expand Up @@ -46,7 +46,7 @@ def set_report(self, report_item):
all_removed = True
for instance_item in instance_items:
item = QtGui.QStandardItem(instance_item.label)
instance_label = html.escape(instance_item.label)
instance_label = html_escape(instance_item.label)
item.setData(instance_label, ITEM_LABEL_ROLE)
item.setData(instance_item.errored, ITEM_ERRORED_ROLE)
item.setData(instance_item.id, ITEM_ID_ROLE)
Expand Down
4 changes: 2 additions & 2 deletions openpype/tools/publisher/widgets/card_view_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

import re
import collections
import html

from Qt import QtWidgets, QtCore

from openpype.widgets.nice_checkbox import NiceCheckbox

from openpype.tools.utils import BaseClickableFrame
from openpype.tools.utils.lib import html_escape
from .widgets import (
AbstractInstanceView,
ContextWarningLabel,
Expand Down Expand Up @@ -308,7 +308,7 @@ def _update_subset_name(self):
self._last_variant = variant
self._last_subset_name = subset_name
# Make `variant` bold
label = html.escape(self.instance.label)
label = html_escape(self.instance.label)
found_parts = set(re.findall(variant, label, re.IGNORECASE))
if found_parts:
for part in found_parts:
Expand Down
6 changes: 3 additions & 3 deletions openpype/tools/publisher/widgets/list_view_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
```
"""
import collections
import html

from Qt import QtWidgets, QtCore, QtGui

from openpype.style import get_objected_colors
from openpype.widgets.nice_checkbox import NiceCheckbox
from openpype.tools.utils.lib import html_escape
from .widgets import AbstractInstanceView
from ..constants import (
INSTANCE_ID_ROLE,
Expand Down Expand Up @@ -114,7 +114,7 @@ def __init__(self, instance, parent):

self.instance = instance

instance_label = html.escape(instance.label)
instance_label = html_escape(instance.label)

subset_name_label = QtWidgets.QLabel(instance_label, self)
subset_name_label.setObjectName("ListViewSubsetName")
Expand Down Expand Up @@ -181,7 +181,7 @@ def update_instance_values(self):
# Check subset name
label = self.instance.label
if label != self._instance_label_widget.text():
self._instance_label_widget.setText(html.escape(label))
self._instance_label_widget.setText(html_escape(label))
# Check active state
self.set_active(self.instance["active"])
# Check valid states
Expand Down
13 changes: 13 additions & 0 deletions openpype/tools/utils/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ def center_window(window):
window.move(geo.topLeft())


def html_escape(text):
"""Basic escape of html syntax symbols in text."""

return (
text
.replace("&", "&")
.replace("<", "&lt;")
.replace(">", "&gt;")
.replace('"', "&quot;")
.replace("'", "&#x27;")
)


def set_style_property(widget, property_name, property_value):
"""Set widget's property that may affect style.

Expand Down