snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
This commit is contained in:
109
apps/meteor/app/utils/lib/getURL.ts
Normal file
109
apps/meteor/app/utils/lib/getURL.ts
Normal file
@@ -0,0 +1,109 @@
|
||||
import { escapeRegExp, isAbsoluteURL } from '@rocket.chat/tools';
|
||||
|
||||
import { ltrim, rtrim, trim } from '../../../lib/utils/stringUtils';
|
||||
|
||||
function getCloudUrl(
|
||||
path: string,
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
_site_url: string,
|
||||
cloudRoute: string,
|
||||
cloudParams: Record<string, string> = {},
|
||||
deeplinkUrl = '',
|
||||
): string {
|
||||
const cloudBaseUrl = deeplinkUrl.replace(/\/+$/, '');
|
||||
|
||||
const siteUrl = rtrim(_site_url, '/');
|
||||
|
||||
// Remove the protocol
|
||||
const host = siteUrl.replace(/https?\:\/\//i, '');
|
||||
path = ltrim(path, '/');
|
||||
|
||||
Object.assign(cloudParams, {
|
||||
host,
|
||||
path,
|
||||
});
|
||||
|
||||
if (siteUrl.includes('http://')) {
|
||||
cloudParams.secure = 'no';
|
||||
}
|
||||
|
||||
const params = Object.entries(cloudParams)
|
||||
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
|
||||
.join('&');
|
||||
|
||||
return `${cloudBaseUrl}/${cloudRoute}?${params}`;
|
||||
}
|
||||
|
||||
export const _getURL = (
|
||||
path: string,
|
||||
|
||||
{ cdn, full, cloud, cloud_route, cloud_params, _cdn_prefix, _root_url_path_prefix, _site_url }: Record<string, any>,
|
||||
deeplinkUrl?: string,
|
||||
): string => {
|
||||
if (isAbsoluteURL(path)) {
|
||||
return path;
|
||||
}
|
||||
|
||||
const [_path, _query] = path.split('?');
|
||||
path = _path;
|
||||
const query = _query ? `?${_query}` : '';
|
||||
|
||||
const siteUrl = rtrim(trim(_site_url || ''), '/');
|
||||
const cloudRoute = trim(cloud_route || '');
|
||||
const cdnPrefix = rtrim(trim(_cdn_prefix || ''), '/');
|
||||
const pathPrefix = rtrim(trim(_root_url_path_prefix || ''), '/');
|
||||
|
||||
const finalPath = ltrim(trim(path), '/');
|
||||
|
||||
const url = rtrim(`${pathPrefix}/${finalPath}`, '/') + query;
|
||||
|
||||
if (cloud) {
|
||||
const cloudParams = cloud_params || {};
|
||||
return getCloudUrl(url, siteUrl, cloudRoute, cloudParams, deeplinkUrl);
|
||||
}
|
||||
|
||||
if (cdn && cdnPrefix !== '') {
|
||||
return cdnPrefix + url;
|
||||
}
|
||||
|
||||
if (full) {
|
||||
return siteUrl.replace(new RegExp(`${escapeRegExp(pathPrefix)}$`), '') + url;
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
export const getURLWithoutSettings = (
|
||||
path: string,
|
||||
|
||||
{
|
||||
cdn = true,
|
||||
full = false,
|
||||
cloud = false,
|
||||
cloud_route = '',
|
||||
cloud_params = {},
|
||||
}: {
|
||||
cdn?: boolean;
|
||||
full?: boolean;
|
||||
cloud?: boolean;
|
||||
cloud_route?: string;
|
||||
cloud_params?: Record<string, string>;
|
||||
},
|
||||
cdnPrefix: string,
|
||||
siteUrl: string,
|
||||
cloudDeepLinkUrl?: string,
|
||||
): string =>
|
||||
_getURL(
|
||||
path,
|
||||
{
|
||||
cdn,
|
||||
full,
|
||||
cloud,
|
||||
cloud_route,
|
||||
cloud_params,
|
||||
_cdn_prefix: cdnPrefix,
|
||||
_root_url_path_prefix: __meteor_runtime_config__.ROOT_URL_PATH_PREFIX,
|
||||
_site_url: siteUrl,
|
||||
},
|
||||
cloudDeepLinkUrl,
|
||||
);
|
||||
6
apps/meteor/app/utils/lib/i18n.ts
Normal file
6
apps/meteor/app/utils/lib/i18n.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { addSprinfToI18n } from '@rocket.chat/i18n';
|
||||
import i18next from 'i18next';
|
||||
import sprintf from 'i18next-sprintf-postprocessor';
|
||||
|
||||
export const i18n = i18next.use(sprintf);
|
||||
export const t = addSprinfToI18n(i18n.t.bind(i18n));
|
||||
89
apps/meteor/app/utils/lib/mimeTypes.spec.ts
Normal file
89
apps/meteor/app/utils/lib/mimeTypes.spec.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { getExtension, getMimeType } from './mimeTypes';
|
||||
|
||||
const mimeTypeToExtension = {
|
||||
'text/plain': 'txt',
|
||||
'image/x-icon': 'ico',
|
||||
'image/vnd.microsoft.icon': 'ico',
|
||||
'image/png': 'png',
|
||||
'image/jpeg': 'jpeg',
|
||||
'image/gif': 'gif',
|
||||
'image/webp': 'webp',
|
||||
'image/svg+xml': 'svg',
|
||||
'image/bmp': 'bmp',
|
||||
'image/tiff': 'tif',
|
||||
'audio/wav': 'wav',
|
||||
'audio/wave': 'wav',
|
||||
'audio/aac': 'aac',
|
||||
'audio/x-aac': 'aac',
|
||||
'audio/mp4': 'm4a',
|
||||
'audio/mpeg': 'mpga',
|
||||
'audio/ogg': 'oga',
|
||||
'application/octet-stream': 'bin',
|
||||
};
|
||||
|
||||
const extensionToMimeType = {
|
||||
lst: 'text/plain',
|
||||
txt: 'text/plain',
|
||||
ico: 'image/x-icon',
|
||||
png: 'image/png',
|
||||
jpeg: 'image/jpeg',
|
||||
gif: 'image/gif',
|
||||
webp: 'image/webp',
|
||||
svg: 'image/svg+xml',
|
||||
bmp: 'image/bmp',
|
||||
tiff: 'image/tiff',
|
||||
tif: 'image/tiff',
|
||||
wav: 'audio/wav',
|
||||
aac: 'audio/aac',
|
||||
mp3: 'audio/mpeg',
|
||||
ogg: 'audio/ogg',
|
||||
oga: 'audio/ogg',
|
||||
m4a: 'audio/mp4',
|
||||
mpga: 'audio/mpeg',
|
||||
mp4: 'video/mp4',
|
||||
bin: 'application/octet-stream',
|
||||
};
|
||||
|
||||
describe('mimeTypes', () => {
|
||||
describe('getExtension', () => {
|
||||
for (const [mimeType, extension] of Object.entries(mimeTypeToExtension)) {
|
||||
it(`should return the correct extension ${extension} for the given mimeType ${mimeType}`, async () => {
|
||||
expect(getExtension(mimeType)).to.be.eql(extension);
|
||||
});
|
||||
}
|
||||
|
||||
it('should return an empty string if the mimeType is not found', async () => {
|
||||
expect(getExtension('application/unknown')).to.be.eql('');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getMimeType', () => {
|
||||
for (const [extension, mimeType] of Object.entries(extensionToMimeType)) {
|
||||
it(`should return the correct mimeType ${mimeType} for the given fileName file.${extension} passing the correct mimeType`, async () => {
|
||||
expect(getMimeType(mimeType, `file.${extension}`)).to.be.eql(mimeType);
|
||||
});
|
||||
}
|
||||
|
||||
it('should return the correct mimeType for the given fileName', async () => {
|
||||
for (const [extension, mimeType] of Object.entries(extensionToMimeType)) {
|
||||
expect(getMimeType('application/unknown', `file.${extension}`)).to.be.eql(mimeType);
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the correct mimeType for the given fileName when informed mimeType is application/octet-stream', async () => {
|
||||
for (const [extension, mimeType] of Object.entries(extensionToMimeType)) {
|
||||
expect(getMimeType('application/octet-stream', `file.${extension}`)).to.be.eql(mimeType);
|
||||
}
|
||||
});
|
||||
|
||||
it('should return the mimeType if it is not application/octet-stream', async () => {
|
||||
expect(getMimeType('audio/wav', 'file.wav')).to.be.eql('audio/wav');
|
||||
});
|
||||
|
||||
it('should return application/octet-stream if the mimeType is not found', async () => {
|
||||
expect(getMimeType('application/octet-stream', 'file.unknown')).to.be.eql('application/octet-stream');
|
||||
});
|
||||
});
|
||||
});
|
||||
31
apps/meteor/app/utils/lib/mimeTypes.ts
Normal file
31
apps/meteor/app/utils/lib/mimeTypes.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import mime from 'mime-type/with-db';
|
||||
|
||||
mime.types.wav = 'audio/wav';
|
||||
mime.types.lst = 'text/plain';
|
||||
mime.define('image/vnd.microsoft.icon', { source: '', extensions: ['ico'] }, mime.dupAppend);
|
||||
mime.define('image/x-icon', { source: '', extensions: ['ico'] }, mime.dupOverwrite);
|
||||
mime.define('audio/aac', { source: '', extensions: ['aac'] }, mime.dupOverwrite);
|
||||
|
||||
const getExtension = (param: string): string => {
|
||||
const extension = mime.extension(param);
|
||||
|
||||
return !extension || typeof extension === 'boolean' ? '' : extension;
|
||||
};
|
||||
|
||||
const getMimeTypeFromFileName = (fileName: string): string => {
|
||||
const fileMimeType = mime.lookup(fileName);
|
||||
return typeof fileMimeType === 'string' ? fileMimeType : 'application/octet-stream';
|
||||
};
|
||||
|
||||
const getMimeType = (mimetype: string, fileName: string): string => {
|
||||
// If the extension from the mimetype is different from the file extension, the file
|
||||
// extension may be wrong so use the informed mimetype
|
||||
const extension = mime.extension(mimetype);
|
||||
if (mimetype !== 'application/octet-stream' && extension && extension !== fileName.split('.').pop()) {
|
||||
return mimetype;
|
||||
}
|
||||
|
||||
return getMimeTypeFromFileName(fileName);
|
||||
};
|
||||
|
||||
export { mime, getExtension, getMimeType, getMimeTypeFromFileName };
|
||||
61
apps/meteor/app/utils/lib/restrictions.ts
Normal file
61
apps/meteor/app/utils/lib/restrictions.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
export const fileUploadMediaWhiteList = function (customWhiteList: string): string[] | undefined {
|
||||
const mediaTypeWhiteList = customWhiteList;
|
||||
|
||||
if (!mediaTypeWhiteList || mediaTypeWhiteList === '*') {
|
||||
return;
|
||||
}
|
||||
return mediaTypeWhiteList.split(',').map((item) => {
|
||||
return item.trim();
|
||||
});
|
||||
};
|
||||
|
||||
const fileUploadMediaBlackList = function (customBlackList: string): string[] | undefined {
|
||||
const blacklist = customBlackList;
|
||||
if (!blacklist) {
|
||||
return;
|
||||
}
|
||||
|
||||
return blacklist.split(',').map((item) => item.trim());
|
||||
};
|
||||
|
||||
const isTypeOnList = function (type?: string, list?: string[]): boolean {
|
||||
if (!type || !list) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (list.includes(type)) {
|
||||
return true;
|
||||
}
|
||||
const wildCardGlob = '/*';
|
||||
const wildcards = list.filter((item) => {
|
||||
return item.indexOf(wildCardGlob) > 0;
|
||||
});
|
||||
if (wildcards.includes(type.replace(/(\/.*)$/, wildCardGlob))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
export const fileUploadIsValidContentTypeFromSettings = function (
|
||||
type: string | undefined,
|
||||
customWhiteList: string,
|
||||
customBlackList: string,
|
||||
): boolean {
|
||||
const blackList = fileUploadMediaBlackList(customBlackList);
|
||||
const whiteList = fileUploadMediaWhiteList(customWhiteList);
|
||||
|
||||
if (blackList && type && isTypeOnList(type, blackList)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (whiteList) {
|
||||
return isTypeOnList(type, whiteList);
|
||||
}
|
||||
|
||||
if (!whiteList) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
2
apps/meteor/app/utils/rocketchat-supported-versions.info
Normal file
2
apps/meteor/app/utils/rocketchat-supported-versions.info
Normal file
@@ -0,0 +1,2 @@
|
||||
{
|
||||
}
|
||||
3
apps/meteor/app/utils/rocketchat.info
Normal file
3
apps/meteor/app/utils/rocketchat.info
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"version": "8.9.0-develop"
|
||||
}
|
||||
Reference in New Issue
Block a user