1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Escape special characters from SVG text

Ref https://github.com/GNS3/gns3-server/issues/952
This commit is contained in:
Julien Duponchelle 2017-03-20 19:14:07 +01:00
parent 5409d9c3f8
commit 55563b9808
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
3 changed files with 7 additions and 4 deletions

View File

@ -18,6 +18,7 @@
import os import os
import re import re
import uuid import uuid
import html
import asyncio import asyncio
import aiohttp import aiohttp
@ -83,7 +84,7 @@ class Link:
"x": -10, "x": -10,
"y": -10, "y": -10,
"rotation": 0, "rotation": 0,
"text": "{}/{}".format(adapter_number, port_number), "text": html.escape("{}/{}".format(adapter_number, port_number)),
"style": "font-size: 10; font-style: Verdana" "style": "font-size: 10; font-style: Verdana"
} }

View File

@ -17,6 +17,7 @@
import aiohttp import aiohttp
import asyncio import asyncio
import html
import copy import copy
import uuid import uuid
import os import os
@ -229,7 +230,7 @@ class Node:
self._label = { self._label = {
"y": round(self._height / 2 + 10) * -1, "y": round(self._height / 2 + 10) * -1,
"text": self._name, "text": html.escape(self._name),
"style": style, "style": style,
"x": None, # None: mean the client should center it "x": None, # None: mean the client should center it
"rotation": 0 "rotation": 0

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import os import os
import html
import json import json
import copy import copy
import uuid import uuid
@ -434,7 +435,7 @@ def _convert_1_3_later(topo, topo_path):
size=int(font_info[1]), size=int(font_info[1]),
weight=weight, weight=weight,
style=style, style=style,
text=note["text"] text=html.escape(note["text"])
) )
new_note = { new_note = {
"drawing_id": str(uuid.uuid4()), "drawing_id": str(uuid.uuid4()),
@ -521,7 +522,7 @@ def _convert_label(label):
""" """
style = qt_font_to_style(label.get("font"), label.get("color")) style = qt_font_to_style(label.get("font"), label.get("color"))
return { return {
"text": label["text"], "text": html.escape(label["text"]),
"rotation": 0, "rotation": 0,
"style": style, "style": style,
"x": int(label["x"]), "x": int(label["x"]),