xwikisas / application-diagram

Create various types of diagrams using draw.io
GNU Lesser General Public License v2.1
0 stars 8 forks source link

Diagram is not shown when importing from URL #320 #322

Open Farcasut opened 4 days ago

Farcasut commented 4 days ago

The issue was caused by a mix of different encodings within the same text. For example, when exporting a diagram, Draw.io generates the following URL:

https://viewer.diagrams.net/?tags=%7B%7D&lightbox=1&highlight=0000ff&edit=_blank&layers=1&nav=1&title=TestDiagram.drawio#R%3Cmxfile%3E%3Cdiagram%20id%3D%22C5RBs43oDa-KdzZeNtuy%22%20name%3D%22Page-1%22%3E7VnbcpswEP0aT5%2FaEcgG8hg7cdLWzaRN2kwfBYhLLRAVwpd%2BfRcjDATqS1s7TiY8ZLTLenU5R7tnSA%2BPosWVIEnwibuU9XTkLnr4oqfrlnEGf3PHsnCYpl44fBG6hUurHHfhL6qcSHmz0KVpI1ByzmSYNJ0Oj2PqyIaPCMHnzTCPs%2BasCfFpy3HnENb2PoSuDNS2dLPyX9PQD8qZtXLDESGbLAAaNSRSy%2FLyuKZtRGTqkow0RFvow74UDcFPRTR6YMox9sIzKul%2BRFepvqz25A2q5%2Fa72ZOk2Ng7ansxme1rb9f6EOvqTdaj%2BZLZYcAt4F2DriK0YcRqqwrUQMrFK2VQb8HTBeT5AqI8OCCfWH8F59tRyw9qlQTzr8n90tVFW8u1yQ9uxRSj2oHcYngaBTl%2BBnO2kZ18lyGEYpr80EVKusManYcbstgqxMxGvRAjP5ItQIQZBaNW2dm5n2ERoNDqiOtG72tlR1UlZUmv0%2BEITEgIt0OSUtAmhlpd%2F8fAFcUPaANSkxKCoC1DDsajtHfFrSB8%2FtT4pK1gTUJYjpKPi5p8Goh4xQG%2B2rydaPV1ojkw8QMdUm1g7HJpgVl%2FOi2Jf%2FfsBX%2F4G%3C%2Fdiagram%3E%3C%2Fmxfile%3E

As we can see, the part after the #R contains the diagram, but we can see that it included two HTML tags that are URL-encoded, followed by a Base64 string. This causes an error when Draw.io attempts to call atob, as the entire string is not properly Base64-encoded, which results in a crash in the atob function and the current behavior. Interestingly, the issue can be reproduce on the latest version of drawio.