Skip to content

[Bug] CSS Selector Syntax Not Validated - Invalid Selectors Cause Silent Failures #136

@anshul23102

Description

@anshul23102

Description

CSS selector input from users is not validated. Invalid selectors silently fail to extract data with no error message. Users believe data was scraped when extraction silently failed.

Steps to Reproduce

  1. User provides CSS selector: "div[class~=invalid" (missing bracket)
  2. Scraper attempts to parse: $('div[class~=invalid')
  3. Selector silently fails
  4. Returns empty results
  5. User assumes no data exists on page

Environment Information

  • Framework: Cheerio/jsdom
  • Input: CSS selector from user
  • Validation: None
  • Application version: Current main branch

Expected Behavior

CSS selectors validated before use. Invalid selectors rejected with clear error message. User can correct and retry.

Actual Behavior

File: src/services/scraper.js
Uses user selector without validation: $(userSelector)

Code Reference

File: src/services/scraper.js
Missing: CSS selector validation

Additional Context

Validate selectors:

try {
  cheerio.parseSelector(userSelector);
} catch (e) {
  return error('Invalid CSS selector');
}

GSSoC Points Estimate: Level 1 (Bug/Validation)

Suggested Labels

  • gssoc:approved
  • type:bug
  • severity:medium
  • area:validation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions