Skip to content

Fix IndexError in search_dates for zh-Hans, zh-Hant, and yue locales - #1377

Open
abhi-0203 wants to merge 1 commit into
scrapinghub:masterfrom
abhi-0203:fix/dateparser-1372
Open

Fix IndexError in search_dates for zh-Hans, zh-Hant, and yue locales#1377
abhi-0203 wants to merge 1 commit into
scrapinghub:masterfrom
abhi-0203:fix/dateparser-1372

Conversation

@abhi-0203

Copy link
Copy Markdown

Summary

Fixes IndexError: list index out of range in search_dates() for zh-Hans, zh-Hant, and yue locales.

Root Cause

In Locale.translate_search() (dateparser/languages/locale.py), the word-joining branch read original_tokens[i + 1] without checking bounds (i < last_token_index), causing an index overflow on the final token when joined forms matched dictionary entries.

Fix

  • Added i < last_token_index bounds check to the word-joining condition.
  • Added regression unit tests covering zh-Hans, zh-Hant, and yue locales in tests/test_search.py.

Closes #1372

… locales

- Add i < last_token_index bounds check in translate_search word-joining branch
- Add regression unit tests for CJK search_dates

Closes scrapinghub#1372
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

search_dates() raises IndexError for the zh-Hans, zh-Hant and yue locales

1 participant