Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/js/groups-domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ function editDomain() {
"/domains/" +
newTypestr +
"/" +
encodeURIComponent(domainDecoded),
utils.encodePathSegment(domainDecoded),
method: "put",
dataType: "json",
processData: false,
Expand Down
2 changes: 1 addition & 1 deletion scripts/js/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ function editGroup() {
utils.disableAll();
utils.showAlert("info", "", "Editing group...", oldName);
$.ajax({
url: document.body.dataset.apiurl + "/groups/" + oldName,
url: document.body.dataset.apiurl + "/groups/" + utils.encodePathSegment(oldName),
method: "put",
dataType: "json",
processData: false,
Expand Down
8 changes: 8 additions & 0 deletions scripts/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,13 @@ function parseQueryString() {
return Object.fromEntries(params.entries());
}

// Encode a string for use as a URL path segment. encodeURIComponent does not
// encode dots, but browsers resolve "." and ".." as relative path components
// before sending the request, breaking domains like "." or "..".
function encodePathSegment(text) {
return encodeURIComponent(text).replaceAll(".", "%2E");
}

function hexEncode(text) {
if (typeof text !== "string" || text.length === 0) return "";

Expand Down Expand Up @@ -726,6 +733,7 @@ globalThis.utils = (function () {
changeTableButtonStates,
getCSSval,
parseQueryString,
encodePathSegment,
hexEncode,
hexDecode,
listsAlert,
Expand Down
Loading