1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-25 16:28:11 +00:00

Fix symbol retrieval issue. Ref #1824

This commit is contained in:
grossmj 2020-10-07 11:48:11 +10:30
parent e014d36ad2
commit d451d3125e
2 changed files with 7 additions and 3 deletions

View File

@ -132,7 +132,7 @@ class Symbols:
return symbol return symbol
else: else:
# return the default computer symbol # return the default computer symbol
log.warning("Could not retrieve symbol '{}'".format(symbol_id)) log.warning("Could not retrieve symbol '{}', returning default symbol...".format(symbol_id))
return self._symbols_path[":/symbols/classic/computer.svg"] return self._symbols_path[":/symbols/classic/computer.svg"]
def get_size(self, symbol_id): def get_size(self, symbol_id):

View File

@ -18,6 +18,7 @@
import os import os
import aiohttp import aiohttp
import asyncio import asyncio
import urllib.parse
from gns3server.web.route import Route from gns3server.web.route import Route
from gns3server.controller import Controller from gns3server.controller import Controller
@ -52,8 +53,9 @@ class SymbolHandler:
async def raw(request, response): async def raw(request, response):
controller = Controller.instance() controller = Controller.instance()
symbol_id = urllib.parse.unquote(request.match_info["symbol_id"])
try: try:
await response.stream_file(controller.symbols.get_path(request.match_info["symbol_id"])) await response.stream_file(controller.symbols.get_path(symbol_id))
except (KeyError, OSError) as e: except (KeyError, OSError) as e:
log.warning("Could not get symbol file: {}".format(e)) log.warning("Could not get symbol file: {}".format(e))
response.set_status(404) response.set_status(404)
@ -66,8 +68,10 @@ class SymbolHandler:
}, },
raw=True) raw=True)
async def upload(request, response): async def upload(request, response):
controller = Controller.instance() controller = Controller.instance()
path = os.path.join(controller.symbols.symbols_path(), os.path.basename(request.match_info["symbol_id"])) symbol_id = urllib.parse.unquote(request.match_info["symbol_id"])
path = os.path.join(controller.symbols.symbols_path(), os.path.basename(symbol_id))
try: try:
with open(path, "wb") as f: with open(path, "wb") as f:
while True: while True: