working #37
@@ -108,4 +108,14 @@ form {
|
||||
background-color: var(--Mistox-Dark)\);
|
||||
height: 40px;
|
||||
break-inside: avoid;
|
||||
}
|
||||
|
||||
.error-window {
|
||||
position: absolute;
|
||||
left: calc(50% - 400px);
|
||||
width: 800px;
|
||||
text-align: center;
|
||||
top: 600px;
|
||||
background-color: red;
|
||||
border-radius: 10px;
|
||||
}
|
||||
@@ -167,4 +167,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
|
||||
@if (ErrorMsg != ""){
|
||||
<div class="error-window">
|
||||
<h1>{{ ErrorMsg }}</h1>
|
||||
</div>
|
||||
}
|
||||
@@ -149,9 +149,10 @@ export class CompanyEditorComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.validator.validateURL(company.websiteURL)[0]){
|
||||
this.ErrorMsg = "Website is invalid";
|
||||
this.focusFrame(3, 1);
|
||||
var urlIsValid = this.validator.validateURL(company.websiteURL);
|
||||
if (urlIsValid[0] == false){
|
||||
this.ErrorMsg = urlIsValid[1];
|
||||
this.focusFrame(1, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -167,8 +168,9 @@ export class CompanyEditorComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.validator.validateEmail(company.email)[0]){
|
||||
this.ErrorMsg = "Email is invalid";
|
||||
var emailIsValid = this.validator.validateEmail(company.email);
|
||||
if (emailIsValid[0] == false){
|
||||
this.ErrorMsg = emailIsValid[1];
|
||||
this.focusFrame(3, 0);
|
||||
return;
|
||||
}
|
||||
@@ -179,7 +181,7 @@ export class CompanyEditorComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.validator.validatePhoneNumber(company.phone)[0]){
|
||||
if (this.validator.validatePhoneNumber(company.phone)[0] == false){
|
||||
this.ErrorMsg = "Phone number is invalid";
|
||||
this.focusFrame(3, 1);
|
||||
return;
|
||||
|
||||
@@ -46,28 +46,28 @@ export class Validation {
|
||||
try {
|
||||
|
||||
if (urlToParse.protocol !== 'http:' && urlToParse.protocol !== 'https:') {
|
||||
return [false, urlToParse.href];
|
||||
return [false, "bad protocol"];
|
||||
}
|
||||
|
||||
const hostname = urlToParse.hostname.toLowerCase();
|
||||
if (hostname === 'localhost' || hostname.endsWith('.localhost')) {
|
||||
return [false, urlToParse.href];
|
||||
return [false, "localhost not allowed"];
|
||||
}
|
||||
|
||||
const privateIpRegex = /^(127\.|10\.|192\.168\.|172\.(1[6-9]|2[0-9]|3[0-1])\.)/;
|
||||
if (privateIpRegex.test(hostname)) {
|
||||
return [false, urlToParse.href];
|
||||
return [false, "internal ipv4 not allowed"];
|
||||
}
|
||||
|
||||
if (hostname.includes(':')) {
|
||||
if (this.isPrivateIPv6(hostname)) {
|
||||
return [false, urlToParse.href];
|
||||
return [false, "internal ipv6 not allowed"];
|
||||
}
|
||||
}
|
||||
|
||||
return [true, urlToParse.href.substring(0, urlToParse.href.length - 1)];
|
||||
} catch (e) {
|
||||
return [false, urlToParse.href];
|
||||
return [false, "validation error has occurred"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user