Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@databases/escape-identifier

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@databases/escape-identifier - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3-canary-1737

lib/__tests__/index.test.d.ts

30

lib/index.js

@@ -11,3 +11,3 @@ "use strict";

function escapePostgresIdentifier(str, { extended = false } = {}) {
validate_unicode_1.default(str);
(0, validate_unicode_1.default)(str);
minLength(str, 'Postgres');

@@ -30,3 +30,3 @@ maxLength(str, 60, 'Postgres', 'https://www.postgresql.org/docs/9.3/sql-syntax-lexical.html');

function escapeMySqlIdentifier(str, { extended = false } = {}) {
validate_unicode_1.default(str);
(0, validate_unicode_1.default)(str);
minLength(str, 'MySQL');

@@ -55,3 +55,3 @@ maxLength(str, 64, 'MySQL', 'http://dev.mysql.com/doc/refman/5.7/en/identifiers.html');

function escapeSQLiteIdentifier(str) {
validate_unicode_1.default(str);
(0, validate_unicode_1.default)(str);
minLength(str, 'SQLite');

@@ -66,15 +66,10 @@ if (str.length > 63) {

function quoteString(str, quoteChar) {
let escaped = quoteChar;
for (const c of str) {
if (c === quoteChar)
escaped += c + c;
else
escaped += c;
}
escaped += quoteChar;
return escaped;
if (!str.includes(quoteChar))
return quoteChar + str + quoteChar;
return (quoteChar + str.split(quoteChar).join(quoteChar + quoteChar) + quoteChar);
}
const NON_ASCII = /[^\u0001-\u007f]/;
function assertAscii(str, db, unicodeAvailable) {
if (!/^[\u0001-\u007f]+$/.test(str)) {
throw new Error(`${db} identifiers may only contain ASCII characters${unicodeAvailable
if (NON_ASCII.test(str)) {
throw new Error(`${db} identifiers must only contain ASCII characters${unicodeAvailable
? ` (to use unicode, pass {extended: true} when escaping the identifier)`

@@ -84,7 +79,8 @@ : ``}`);

}
const NON_UNICODE = /[^\u0001-\uffff]/;
function assertUnicode(str, db) {
// U+0001 .. U+007F
// U+0080 .. U+FFFF
if (!/^[\u0001-\uffff]+$/.test(str)) {
throw new Error(`${db} identifiers should only contain charcters in the range: U+0001 .. U+FFFF`);
if (NON_UNICODE.test(str)) {
throw new Error(`${db} identifiers must only contain characters in the range: U+0001 .. U+FFFF`);
}

@@ -99,5 +95,5 @@ }

if (str.length > length) {
throw new Error(`${db} identifiers should not be longer than ${length} characters. ${str}`);
throw new Error(`${db} identifiers must not be longer than ${length} characters. ${str}`);
}
}
//# sourceMappingURL=index.js.map
{
"name": "@databases/escape-identifier",
"version": "1.0.2",
"version": "1.0.3-canary-1737",
"description": "",

@@ -8,3 +8,3 @@ "main": "./lib/index.js",

"dependencies": {
"@databases/validate-unicode": "^1.0.0"
"@databases/validate-unicode": "1.0.0"
},

@@ -11,0 +11,0 @@ "scripts": {},

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc