Skip to content
This repository has been archived by the owner on Mar 23, 2021. It is now read-only.

Commit

Permalink
Update susSettings.php
Browse files Browse the repository at this point in the history
Force trailing slash in SUS URL validation
  • Loading branch information
Duncan McCracken authored and Duncan McCracken committed Jul 31, 2019
1 parent 35bf7c0 commit 0b5da63
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions webadmin/var/www/webadmin/susSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ function hideSuccess(element) {

function validBaseUrl(element, labelId = false) {
hideSuccess(element);
if (/^http(s)?:\/\/(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][\/]|[1-9][0-9]|[1-9][0-9][\/]|1[0-9]{2}|1[0-9]{2}[\/]|2[0-4][0-9]|2[0-4][0-9][\/]|25[0-5]|25[0-5][\/])$|^http(s)?:\/\/(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][\/]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9][\/])$/.test(element.value)) {
if (/^http(s)?:\/\/(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9]|[1-9][0-9]|[1-9][0-9]|1[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|2[0-4][0-9]|25[0-5]|25[0-5])\/$|^http(s)?:\/\/(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])\/$/.test(element.value)) {
hideError(element, labelId);
} else {
showError(element, labelId);
}
}

function updateBaseUrl(element, offset = false) {
if (/^http(s)?:\/\/(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][\/]|[1-9][0-9]|[1-9][0-9][\/]|1[0-9]{2}|1[0-9]{2}[\/]|2[0-4][0-9]|2[0-4][0-9][\/]|25[0-5]|25[0-5][\/])$|^http(s)?:\/\/(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][\/]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9][\/])$/.test(element.value)) {
if (/^http(s)?:\/\/(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9]|[1-9][0-9]|[1-9][0-9]|1[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|2[0-4][0-9]|25[0-5]|25[0-5])\/$|^http(s)?:\/\/(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])\/$/.test(element.value)) {
ajaxPost('susCtl.php', 'baseurl='+element.value);
showSuccess(element);
}
Expand Down Expand Up @@ -281,7 +281,7 @@ function toggleDashboard() {
<hr>

<div style="padding: 9px 20px 1px;">
<h5 id="baseurl_label"><strong>Base URL</strong> <small>Base URL for the software update server (e.g. "http://sus.mycompany.corp").</small></h5>
<h5 id="baseurl_label"><strong>Base URL</strong> <small>Base URL for the software update server (e.g. "http://sus.mycompany.corp/").</small></h5>
<div class="form-group has-feedback">
<input type="text" name="baseurl" id="baseurl" class="form-control input-sm long-text-input" placeholder="[Required]" value="<?php echo $susbaseurl; ?>" onFocus="validBaseUrl(this, 'baseurl_label');" onKeyUp="validBaseUrl(this, 'baseurl_label');" onChange="updateBaseUrl(this);"/>
</div>
Expand Down

0 comments on commit 0b5da63

Please sign in to comment.