{"record":{"id":"a1f32c960fdfa7f2","repo":"OrchardCMS/OrchardCore","slug":"syntax-error-unrecognized-expression-a1f32c","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.5.1/jquery.slim.js","lineNumber":1677,"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":1659,"sourceCodeEnd":1695,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Vendor/jquery-3.5.1/jquery.slim.js#L1659-L1695","documentation":"The slim build bundles the same Sizzle selector engine, so it throws the identical 'Syntax error, unrecognized expression' when a selector string cannot be parsed or uses unsupported pseudo-selectors. The offending selector text is appended to the message.","triggerScenarios":"$(expr)/find(expr)/closest(expr) with malformed strings — unbalanced quotes, brackets or parens — or unknown pseudo-classes; passing a value jQuery cannot coerce into a selector, element, or array-like.","commonSituations":"Interpolating user input into selector strings; typos or removed plugin pseudo-selectors; selectors generated from configuration or attributes containing special characters like . # : [ ].","solutions":["Extract the selector text from the message after 'Syntax error, unrecognized expression: ' and validate/escape it at the call site.","Replace string-interpolated selectors with .filter(fn) or attribute-comparison helpers, or escape special chars using jQuery.escapeSelector / Sizzle.escape.","Register missing custom pseudo-selectors via $.expr.pseudos, or use the full (non-slim) build if a plugin requires it.","Prefer passing DOM node references to $() instead of composed selector strings for dynamic values."],"exampleFix":"// before\n$('.' + rawClassName); // throws if rawClassName has spaces/brackets\n// after\n$(document.querySelectorAll('[class]')).filter(function(){\n  return this.classList.contains(rawClassName);\n});","handlingStrategy":"validation","validationCode":"function safeSelect(sel) {\n  try { document.querySelector(sel); return true; }\n  catch (e) { return false; }\n}\nif (safeSelect(mySelector)) { $(mySelector); } else { console.warn('Invalid selector skipped:', mySelector); }","typeGuard":"function isPlainSelector(v) { return typeof v === 'string' && !/[\\u0000-\\u001f]/.test(v) && v.trim().length > 0; }","tryCatchPattern":"try { $el = $(sel); } catch (e) { if (String(e.message).includes('unrecognized expression')) { $el = $(); console.warn('Rejected selector', sel); } else { throw e; } }","preventionTips":["Escape special characters with $.escapeSelector in dynamic selectors.","Reject or sanitize user input used inside selector strings.","Verify custom :pseudo plugins are loaded on the slim build too.","Unit-test generated selectors before shipping."],"tags":["jquery","slim","sizzle","selector","syntax"],"backgroundTag":"invalid-argument-format","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"}