Replace CDN React/ReactDOM/Babel with local libs; remove Babel and inline scripts Build Tailwind locally, add safelist; switch to assets/tailwind.css Self-host Font Awesome and Inter (CSS + woff2); remove external font CDNs Implement strict CSP (no unsafe-inline/eval; scripts/styles/fonts from self) Extract inline handlers; move PWA scripts to external files Add local QR code generation (qrcode lib) and remove api.qrserver.com Improve SessionTypeSelector visual selection (highlighted background and ring) Keep PWA working with service worker and offline assets Refs: CSP hardening, offline-first, no external dependencies
32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
const numeric = '[0-9]+'
|
|
const alphanumeric = '[A-Z $%*+\\-./:]+'
|
|
let kanji = '(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|' +
|
|
'[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|' +
|
|
'[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|' +
|
|
'[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+'
|
|
kanji = kanji.replace(/u/g, '\\u')
|
|
|
|
const byte = '(?:(?![A-Z0-9 $%*+\\-./:]|' + kanji + ')(?:.|[\r\n]))+'
|
|
|
|
exports.KANJI = new RegExp(kanji, 'g')
|
|
exports.BYTE_KANJI = new RegExp('[^A-Z0-9 $%*+\\-./:]+', 'g')
|
|
exports.BYTE = new RegExp(byte, 'g')
|
|
exports.NUMERIC = new RegExp(numeric, 'g')
|
|
exports.ALPHANUMERIC = new RegExp(alphanumeric, 'g')
|
|
|
|
const TEST_KANJI = new RegExp('^' + kanji + '$')
|
|
const TEST_NUMERIC = new RegExp('^' + numeric + '$')
|
|
const TEST_ALPHANUMERIC = new RegExp('^[A-Z0-9 $%*+\\-./:]+$')
|
|
|
|
exports.testKanji = function testKanji (str) {
|
|
return TEST_KANJI.test(str)
|
|
}
|
|
|
|
exports.testNumeric = function testNumeric (str) {
|
|
return TEST_NUMERIC.test(str)
|
|
}
|
|
|
|
exports.testAlphanumeric = function testAlphanumeric (str) {
|
|
return TEST_ALPHANUMERIC.test(str)
|
|
}
|