Skip to content

Commit 9f2ff54

Browse files
committed
Restricts processing public shares to diagrams only [#133]
1 parent a0b742f commit 9f2ff54

4 files changed

Lines changed: 17 additions & 7 deletions

File tree

appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- Supports public share links (read-only and editable)
1616
- Offline mode for privacy-sensitive deployments
1717
- Configurable editor URL for self-hosted diagrams.net instances]]></description>
18-
<version>4.2.2</version>
18+
<version>4.2.3</version>
1919
<licence>agpl</licence>
2020
<author>draw.io Ltd</author>
2121
<namespace>Drawio</namespace>

js/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "drawio",
33
"description": "Integrates draw.io diagrams editor with Nextcloud",
4-
"version": "4.2.2",
4+
"version": "4.2.3",
55
"author": "draw.io Ltd",
66

77
"license": "agpl",

src/main.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,23 @@ $(function ()
8383
{
8484
OCA.DrawIO.init();
8585

86-
// Sometimes the file doesn't open, so we add a delayed attempt as well
87-
setTimeout(() =>
86+
// On public share pages, auto-open if the shared file is a diagram
87+
setTimeout(async () =>
8888
{
8989
if (window.location.pathname.startsWith('/s/'))
9090
{
91-
// TODO Add whiteboard support for public shares
92-
OCA.DrawIO.OpenEditor(null, false);
91+
var shareToken = getSharingToken();
92+
if (!shareToken) return;
93+
94+
try {
95+
var url = generateUrl('/apps/' + OCA.DrawIO.AppName + '/ajax/getFileInfo?shareToken={shareToken}', { shareToken: shareToken });
96+
var response = await $.get(url);
97+
if (response && (response.mime === 'application/x-drawio' || response.mime === 'application/x-drawio-wb')) {
98+
OCA.DrawIO.OpenEditor(null, response.mime === 'application/x-drawio-wb');
99+
}
100+
} catch (e) {
101+
// Not a diagram file or share not accessible — don't redirect
102+
}
93103
}
94104
}, 10000);
95105
});

0 commit comments

Comments
 (0)