Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Strict parsing regex is not escaped properly #4631

Closed
alaeMellon opened this issue May 17, 2018 · 4 comments
Closed

[bug] Strict parsing regex is not escaped properly #4631

alaeMellon opened this issue May 17, 2018 · 4 comments
Labels

Comments

@alaeMellon
Copy link

When I'm using

moment().locale("en");
moment("Th 17.05.2018", "dd DD.MM.YYYY", "en").format()
-> Result: "2018-05-17T00:00:00Z"
This is fine.

But when I'm using de there is a problem:

moment().locale("de");
moment("Di 15.05.18", "dd DD.MM.YYYY", "de").format()
-> Result: "Invalid date"

Does anybody know whats wrong?
Thanks for your help!

@uvenil
Copy link

uvenil commented May 19, 2018

Bitte versuche:
moment().locale("de");
moment("Di 15.05.2018", "dd DD.MM.YYYY", "de").format()

@alaeMellon
Copy link
Author

uvenil, right. This was a copy+paste problem.

But my problem still remains.

I made an jsfiddle: https://jsfiddle.net/m9c3Lde1/

@ichernev
Copy link
Contributor

@alaeMellon you're correct we have a bug here.

The problem is that German ddd includes dots, which forces weekdaysParseExact: true, which in turn generates a regex from all possible weekday strings, but unfortunately forgets to escape the dot. So now the dot matches the space, and then Di_ fails to match a proper weekday string (which is only Di or Di.).

@ichernev ichernev changed the title Problem: Parsing german string to moment-object [bug] Strict parsing regex is not escaped properly Jun 27, 2018
@marwahaha marwahaha added the Bug label Jan 17, 2019
Alanscut added a commit to Alanscut/moment that referenced this issue Apr 29, 2020
@marwahaha
Copy link
Member

I can no longer reproduce this.
Please re-open if you still have concerns.
Hope it's working on your side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants