Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept tabs inside dns.hosts and strip possible trailing comments #3241

Merged
merged 1 commit into from
Feb 22, 2025
Merged
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
16 changes: 12 additions & 4 deletions scripts/js/settings-dns-records.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,34 @@

function hostsDomain(data) {
// Split record in format IP NAME1 [NAME2 [NAME3 [NAME...]]]
const name = data.substring(data.indexOf(" ") + 1);
// We split both on spaces and tabs to support both formats
// Also, we remove any comments after the name(s)
const name = data
.split(/[\t ]+/)
.slice(1)
.join(" ")
.split("#")[0]
.trim();
return name;
}

function hostsIP(data) {
// Split record in format IP NAME1 [NAME2 [NAME3 [NAME...]]]
const ip = data.substring(0, data.indexOf(" "));
// We split both on spaces and tabs to support both formats
const ip = data.split(/[\t ]+/)[0].trim();
return ip;
}

function CNAMEdomain(data) {
// Split record in format <cname>,<target>[,<TTL>]
const CNAMEarr = data.split(",");
return CNAMEarr[0];
return CNAMEarr[0].trim();
}

function CNAMEtarget(data) {
// Split record in format <cname>,<target>[,<TTL>]
const CNAMEarr = data.split(",");
return CNAMEarr[1];
return CNAMEarr[1].trim();
}

function CNAMEttl(data) {
Expand Down