Skip to content

Commit

Permalink
Fixing eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Nov 5, 2024
1 parent 94a34a5 commit 60d59cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/admin/src/lib/testPassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const mutableStdout = new Writable({
},
});

// eslint-disable-next-line @typescript-eslint/no-floating-promises
checkWellKnownPasswords().then(found => {
if (found) {
console.log(`Found well-known password: ${JSON.stringify(found)}`);
Expand Down
22 changes: 11 additions & 11 deletions packages/admin/src/lib/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ import * as session from 'express-session';
import * as bodyParser from 'body-parser';
import * as cookieParser from 'cookie-parser';

function isLocalUrl(path: string): boolean {
try {
return new URL(path, "http://127.0.0.1:3000").origin === "http://127.0.0.1:3000";
} catch (e) {
return false;
}
}

export interface AdminAdapterConfig extends ioBroker.AdapterConfig {
accessAllowedConfigs: string[];
accessAllowedTabs: string[];
Expand Down Expand Up @@ -123,6 +115,14 @@ function escapeHtml(string: string): string {
return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
}

function isLocalUrl(path: string): boolean {
try {
return new URL(path, 'http://127.0.0.1:3000').origin === 'http://127.0.0.1:3000';
} catch {
return false;
}
}

function get404Page(customText?: string): string {
if (customText) {
return page404.replace('<div class="custom-message"></div>', `<div class="custom-message">${customText}</div>`);
Expand Down Expand Up @@ -622,10 +622,10 @@ class Web {
req.body = req.body || {};
const isDev = req.url.includes('?dev&');

const origin = req.body.origin || '?href=%2F';
const origin = (req.body.origin || '?href=%2F').trim();
if (origin) {
const parts = origin.match(/href=(.+)$/);
if (parts && parts.length > 1 && parts[1]) {
const parts = origin.split('href=');
if (parts?.length > 1 && parts[1]) {
redirect = decodeURIComponent(parts[1]);
// if some invalid characters in redirect
if (redirect.match(/[^-_a-zA-Z0-9&%?./]/) || !isLocalUrl(redirect)) {
Expand Down

0 comments on commit 60d59cf

Please sign in to comment.