Skip to content

Commit 9f47ec8

Browse files
Fixes #98
1 parent 6939784 commit 9f47ec8

File tree

4 files changed

+28
-23
lines changed

4 files changed

+28
-23
lines changed

structurizr-onpremises/src/main/java/com/structurizr/onpremises/web/workspace/DecisionsController.java

+9-6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import org.springframework.web.bind.annotation.RequestMethod;
1111
import org.springframework.web.bind.annotation.RequestParam;
1212

13+
import java.nio.charset.StandardCharsets;
14+
import java.util.Base64;
15+
1316
@Controller
1417
public class DecisionsController extends AbstractWorkspaceController {
1518

@@ -55,7 +58,7 @@ public String showPublicDecisions(
5558
@PathVariable("component") String component,
5659
ModelMap model
5760
) {
58-
model.addAttribute("scope", toScope(softwareSystem, container, component));
61+
model.addAttribute("scope", Base64.getEncoder().encodeToString(toScope(softwareSystem, container, component).getBytes(StandardCharsets.UTF_8)));
5962
model.addAttribute("showHeader", true);
6063

6164
return showPublicView(VIEW, workspaceId, version, model, false);
@@ -104,7 +107,7 @@ public String showSharedDecisions(
104107
@PathVariable("token") String token,
105108
ModelMap model
106109
) {
107-
model.addAttribute("scope", toScope(softwareSystem, container, component));
110+
model.addAttribute("scope", Base64.getEncoder().encodeToString(toScope(softwareSystem, container, component).getBytes(StandardCharsets.UTF_8)));
108111
model.addAttribute("showHeader", true);
109112

110113
return showSharedView(VIEW, workspaceId, token, version, model, false);
@@ -155,19 +158,19 @@ public String showAuthenticatedDecisions(
155158
return show404Page(model);
156159
}
157160

158-
model.addAttribute("scope", toScope(softwareSystem, container, component));
161+
model.addAttribute("scope", Base64.getEncoder().encodeToString(toScope(softwareSystem, container, component).getBytes(StandardCharsets.UTF_8)));
159162
model.addAttribute("showHeader", true);
160163

161164
return showAuthenticatedView(VIEW, workspaceMetaData, version, model, false, false);
162165
}
163166

164167
String toScope(String softwareSystem, String container, String component) {
165168
if (softwareSystem != null && container != null && component != null) {
166-
return HtmlUtils.filterHtml(softwareSystem) + "/" + HtmlUtils.filterHtml(container) + "/" + HtmlUtils.filterHtml(component);
169+
return softwareSystem + "/" + container + "/" + component;
167170
} else if (softwareSystem != null && container != null) {
168-
return HtmlUtils.filterHtml(softwareSystem) + "/" + HtmlUtils.filterHtml(container);
171+
return softwareSystem + "/" + container;
169172
} else if (softwareSystem != null) {
170-
return HtmlUtils.filterHtml(softwareSystem);
173+
return softwareSystem;
171174
} else {
172175
return WORKSPACE_SCOPE;
173176
}

structurizr-onpremises/src/main/java/com/structurizr/onpremises/web/workspace/DocumentationController.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.structurizr.onpremises.web.workspace;
22

33
import com.structurizr.onpremises.component.workspace.WorkspaceMetaData;
4-
import com.structurizr.onpremises.util.HtmlUtils;
54
import org.springframework.security.access.prepost.PreAuthorize;
65
import org.springframework.stereotype.Controller;
76
import org.springframework.ui.ModelMap;
@@ -10,6 +9,9 @@
109
import org.springframework.web.bind.annotation.RequestMethod;
1110
import org.springframework.web.bind.annotation.RequestParam;
1211

12+
import java.nio.charset.StandardCharsets;
13+
import java.util.Base64;
14+
1315
@Controller
1416
public class DocumentationController extends AbstractWorkspaceController {
1517

@@ -55,7 +57,7 @@ public String showPublicDocumentation(
5557
@PathVariable("component") String component,
5658
ModelMap model
5759
) {
58-
model.addAttribute("scope", toScope(softwareSystem, container, component));
60+
model.addAttribute("scope", Base64.getEncoder().encodeToString(toScope(softwareSystem, container, component).getBytes(StandardCharsets.UTF_8)));
5961
model.addAttribute("showHeader", true);
6062

6163
return showPublicView(VIEW, workspaceId, version, model, false);
@@ -104,7 +106,7 @@ public String showSharedDocumentation(
104106
@PathVariable("token") String token,
105107
ModelMap model
106108
) {
107-
model.addAttribute("scope", toScope(softwareSystem, container, component));
109+
model.addAttribute("scope", Base64.getEncoder().encodeToString(toScope(softwareSystem, container, component).getBytes(StandardCharsets.UTF_8)));
108110
model.addAttribute("showHeader", true);
109111

110112
return showSharedView(VIEW, workspaceId, token, version, model, false);
@@ -155,19 +157,19 @@ public String showAuthenticatedDocumentation(
155157
return show404Page(model);
156158
}
157159

158-
model.addAttribute("scope", toScope(softwareSystem, container, component));
160+
model.addAttribute("scope", Base64.getEncoder().encodeToString(toScope(softwareSystem, container, component).getBytes(StandardCharsets.UTF_8)));
159161
model.addAttribute("showHeader", true);
160162

161163
return showAuthenticatedView(VIEW, workspaceMetaData, version, model, false, false);
162164
}
163165

164166
String toScope(String softwareSystem, String container, String component) {
165167
if (softwareSystem != null && container != null && component != null) {
166-
return HtmlUtils.filterHtml(softwareSystem) + "/" + HtmlUtils.filterHtml(container) + "/" + HtmlUtils.filterHtml(component);
168+
return softwareSystem + "/" + container + "/" + component;
167169
} else if (softwareSystem != null && container != null) {
168-
return HtmlUtils.filterHtml(softwareSystem) + "/" + HtmlUtils.filterHtml(container);
170+
return softwareSystem + "/" + container;
169171
} else if (softwareSystem != null) {
170-
return HtmlUtils.filterHtml(softwareSystem);
172+
return softwareSystem;
171173
} else {
172174
return WORKSPACE_SCOPE;
173175
}

structurizr-onpremises/src/test/java/com/structurizr/onpremises/web/workspace/DecisionsControllerTests.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public String getWorkspace(long workspaceId, String version) throws WorkspaceCom
7878
assertSame(workspaceMetaData, model.getAttribute("workspace"));
7979
assertEquals("anNvbg==", model.getAttribute("workspaceAsJson"));
8080
assertEquals("/share/1", model.getAttribute("urlPrefix"));
81-
assertEquals("*", model.getAttribute("scope"));
81+
assertEquals("Kg==", model.getAttribute("scope"));
8282
}
8383

8484
@Test
@@ -154,7 +154,7 @@ public String getWorkspace(long workspaceId, String version) throws WorkspaceCom
154154
assertSame(workspaceMetaData, model.getAttribute("workspace"));
155155
assertEquals("anNvbg==", model.getAttribute("workspaceAsJson"));
156156
assertEquals("/share/1/token", model.getAttribute("urlPrefix"));
157-
assertEquals("*", model.getAttribute("scope"));
157+
assertEquals("Kg==", model.getAttribute("scope"));
158158
}
159159

160160
@Test
@@ -213,7 +213,7 @@ public String getWorkspace(long workspaceId, String version) throws WorkspaceCom
213213
assertSame(workspaceMetaData, model.getAttribute("workspace"));
214214
assertEquals("anNvbg==", model.getAttribute("workspaceAsJson"));
215215
assertEquals("/workspace/1", model.getAttribute("urlPrefix"));
216-
assertEquals("*", model.getAttribute("scope"));
216+
assertEquals("Kg==", model.getAttribute("scope"));
217217
}
218218

219219
@Test
@@ -238,7 +238,7 @@ public String getWorkspace(long workspaceId, String version) throws WorkspaceCom
238238
assertSame(workspaceMetaData, model.getAttribute("workspace"));
239239
assertEquals("anNvbg==", model.getAttribute("workspaceAsJson"));
240240
assertEquals("/workspace/1", model.getAttribute("urlPrefix"));
241-
assertEquals("*", model.getAttribute("scope"));
241+
assertEquals("Kg==", model.getAttribute("scope"));
242242
}
243243

244244
@Test
@@ -263,7 +263,7 @@ public String getWorkspace(long workspaceId, String version) throws WorkspaceCom
263263
assertSame(workspaceMetaData, model.getAttribute("workspace"));
264264
assertEquals("anNvbg==", model.getAttribute("workspaceAsJson"));
265265
assertEquals("/workspace/1", model.getAttribute("urlPrefix"));
266-
assertEquals("*", model.getAttribute("scope"));
266+
assertEquals("Kg==", model.getAttribute("scope"));
267267
}
268268

269269
@Test

structurizr-onpremises/src/test/java/com/structurizr/onpremises/web/workspace/DocumentationControllerTests.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public String getWorkspace(long workspaceId, String version) throws WorkspaceCom
7878
assertSame(workspaceMetaData, model.getAttribute("workspace"));
7979
assertEquals("anNvbg==", model.getAttribute("workspaceAsJson"));
8080
assertEquals("/share/1", model.getAttribute("urlPrefix"));
81-
assertEquals("*", model.getAttribute("scope"));
81+
assertEquals("Kg==", model.getAttribute("scope"));
8282
}
8383

8484
@Test
@@ -154,7 +154,7 @@ public String getWorkspace(long workspaceId, String version) throws WorkspaceCom
154154
assertSame(workspaceMetaData, model.getAttribute("workspace"));
155155
assertEquals("anNvbg==", model.getAttribute("workspaceAsJson"));
156156
assertEquals("/share/1/token", model.getAttribute("urlPrefix"));
157-
assertEquals("*", model.getAttribute("scope"));
157+
assertEquals("Kg==", model.getAttribute("scope"));
158158
}
159159

160160
@Test
@@ -213,7 +213,7 @@ public String getWorkspace(long workspaceId, String version) throws WorkspaceCom
213213
assertSame(workspaceMetaData, model.getAttribute("workspace"));
214214
assertEquals("anNvbg==", model.getAttribute("workspaceAsJson"));
215215
assertEquals("/workspace/1", model.getAttribute("urlPrefix"));
216-
assertEquals("*", model.getAttribute("scope"));
216+
assertEquals("Kg==", model.getAttribute("scope"));
217217
}
218218

219219
@Test
@@ -238,7 +238,7 @@ public String getWorkspace(long workspaceId, String version) throws WorkspaceCom
238238
assertSame(workspaceMetaData, model.getAttribute("workspace"));
239239
assertEquals("anNvbg==", model.getAttribute("workspaceAsJson"));
240240
assertEquals("/workspace/1", model.getAttribute("urlPrefix"));
241-
assertEquals("*", model.getAttribute("scope"));
241+
assertEquals("Kg==", model.getAttribute("scope"));
242242
}
243243

244244
@Test
@@ -263,7 +263,7 @@ public String getWorkspace(long workspaceId, String version) throws WorkspaceCom
263263
assertSame(workspaceMetaData, model.getAttribute("workspace"));
264264
assertEquals("anNvbg==", model.getAttribute("workspaceAsJson"));
265265
assertEquals("/workspace/1", model.getAttribute("urlPrefix"));
266-
assertEquals("*", model.getAttribute("scope"));
266+
assertEquals("Kg==", model.getAttribute("scope"));
267267
}
268268

269269
@Test

0 commit comments

Comments
 (0)