diff --git a/gradio/routes.py b/gradio/routes.py index 76280c2d56..a424714ce8 100644 --- a/gradio/routes.py +++ b/gradio/routes.py @@ -18,6 +18,7 @@ from typing import Any, Dict, List, Optional, Type from urllib.parse import urlparse import fastapi +import markupsafe import orjson import pkg_resources from fastapi import Depends, FastAPI, HTTPException, WebSocket, status @@ -31,7 +32,6 @@ from fastapi.responses import ( from fastapi.security import OAuth2PasswordRequestForm from fastapi.templating import Jinja2Templates from jinja2.exceptions import TemplateNotFound -from jinja2.utils import htmlsafe_json_dumps from starlette.responses import RedirectResponse from starlette.websockets import WebSocketState @@ -73,7 +73,13 @@ class ORJSONResponse(JSONResponse): def toorjson(value): - return htmlsafe_json_dumps(value, dumps=ORJSONResponse._render_str) + return markupsafe.Markup( + ORJSONResponse._render_str(value) + .replace("<", "\\u003c") + .replace(">", "\\u003e") + .replace("&", "\\u0026") + .replace("'", "\\u0027") + ) templates = Jinja2Templates(directory=STATIC_TEMPLATE_LIB) diff --git a/gradio/version.txt b/gradio/version.txt index c10780c628..3e388a4ac9 100644 --- a/gradio/version.txt +++ b/gradio/version.txt @@ -1 +1 @@ -3.13.1 +3.13.2 diff --git a/requirements.txt b/requirements.txt index 146761b039..9d59f3de1d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,7 @@ altair fastapi ffmpy markdown-it-py[linkify,plugins] +markupsafe matplotlib numpy orjson