Open stevenvdr opened 6 years ago
The function getCookies https://github.com/neutronX/django-markdownx/blob/de43019c84b5ae0512c89c7f8d9d08cdfd3b9393/markdownx/static/markdownx/js/markdownx.js#L589 reads out the cookies and then tries to match them against the given name. The function however matches name+'=' anywhere in the string so that also subname + name + '=' will be matched, causing the wrong cookie to be returned.
name+'='
subname + name + '='
The function is used to get the 'csrftoken' cookie. The result of an incorrect lookup means that the csrf token will be rejected by the server.
An easy fix is to change the following line:
- .filter(cookie => cookie.indexOf(`${name}=`) !== -1)[0]; + .filter(cookie => cookie.trim().indexOf(`${name}=`) == 0)[0];
Would it be possible to fix this?
Thanks for pointing this out. I'll get onto this next week... or you can do it yourself an submit a pull request?
Please close this issue as it has been fixed on #172
The function getCookies https://github.com/neutronX/django-markdownx/blob/de43019c84b5ae0512c89c7f8d9d08cdfd3b9393/markdownx/static/markdownx/js/markdownx.js#L589 reads out the cookies and then tries to match them against the given name. The function however matches
name+'='
anywhere in the string so that alsosubname + name + '='
will be matched, causing the wrong cookie to be returned.The function is used to get the 'csrftoken' cookie. The result of an incorrect lookup means that the csrf token will be rejected by the server.
An easy fix is to change the following line:
Would it be possible to fix this?