{"record":{"id":"1c60ab60693a6ce1","repo":"OrchardCMS/OrchardCore","slug":"syntax-error-unrecognized-expression","errorCode":null,"errorMessage":"Syntax error, unrecognized expression: ","messagePattern":"Syntax error, unrecognized expression: ","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Vendor/jquery-3.4.1/jquery.js","lineNumber":1560,"sourceCode":"\t\tval = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?\n\t\t\tfn( elem, name, !documentIsHTML ) :\n\t\t\tundefined;\n\n\treturn val !== undefined ?\n\t\tval :\n\t\tsupport.attributes || !documentIsHTML ?\n\t\t\telem.getAttribute( name ) :\n\t\t\t(val = elem.getAttributeNode(name)) && val.specified ?\n\t\t\t\tval.value :\n\t\t\t\tnull;\n};\n\nSizzle.escape = function( sel ) {\n\treturn (sel + \"\").replace( rcssescape, fcssescape );\n};\n\nSizzle.error = function( msg ) {\n\tthrow new Error( \"Syntax error, unrecognized expression: \" + msg );\n};\n\n/**\n * Document sorting and removing duplicates\n * @param {ArrayLike} results\n */\nSizzle.uniqueSort = function( results ) {\n\tvar elem,\n\t\tduplicates = [],\n\t\tj = 0,\n\t\ti = 0;\n\n\t// Unless we *know* we can detect duplicates, assume their presence\n\thasDuplicate = !support.detectDuplicates;\n\tsortInput = !support.sortStable && results.slice( 0 );\n\tresults.sort( sortOrder );\n\n\tif ( hasDuplicate ) {","sourceCodeStart":1542,"sourceCodeEnd":1578,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Vendor/jquery-3.4.1/jquery.js#L1542-L1578","documentation":"Sizzle.error is Sizzle/jQuery's way of reporting malformed selector expressions: it throws new Error('Syntax error, unrecognized expression: ' + msg). When a CSS selector string cannot be tokenized or matched by Sizzle's grammar, this error is raised from jQuery's selector engine.","triggerScenarios":"Passing an empty or syntactically invalid selector to $()/jQuery(), e.g. $(''), $('#'), $('div['), or a selector containing unescaped special characters; also find()/filter()/is() with invalid expressions.","commonSituations":"Dynamically built selectors from empty variables or user input; attribute selectors with unquoted values; selectors containing unescaped dots in IDs (e.g. from .NET names like asp-for controls); templates where a variable is empty at render time.","solutions":["Validate/interpolate the selector string before use; guard against empty values","Escape special characters with CSS.escape for ids/classes containing dots or colons","Use document.querySelector-compatible valid selector syntax","Check the variable feeding the selector is not undefined/empty"],"exampleFix":"// before\nvar id = ''; $(id); // Syntax error, unrecognized expression:\n// after\nif (id) { $(CSS.escape ? '#' + CSS.escape(id) : '#' + id.replace(/([:.])/g, '\\\\$1')); }","handlingStrategy":"validation","validationCode":"function isSafeSelector(sel) { return typeof sel === 'string' && sel.trim().length > 0 && !/[<>]|\\[\\s*\\]|\\(\\s*\\)/.test(sel); }","typeGuard":"function isNonEmptyString(v) { return typeof v === 'string' && v.trim().length > 0; }","tryCatchPattern":"try { $(sel); } catch (e) { if (e.message.startsWith('Syntax error, unrecognized expression')) { console.error('Bad selector:', sel); } else { throw e; } }","preventionTips":["Check selector variables are non-empty strings before $()","Escape ids containing dots/colons (common with ASP.NET asp-for ids) with CSS.escape","Quote attribute selector values: [data-x=\"1\"]","Never pass user input directly into selectors without validation"],"tags":["javascript","jquery","sizzle","selector","syntax"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}