[Users] glib regex issue is stopping OAuth2 token update
Dan N
dhn2-linux at stanfordalumni.org
Mon Oct 17 20:19:02 UTC 2022
I've been successfully using OAuth2 (In Production, claws-mail 4.1.0, Linux)
with gmail POP for a few months, ever since gmail began requiring it. Starting
3-4 weeks ago something changed in Google's server response causing random
failures (at least once a day) of token update and giving log message "OAuth2
access token not obtained". Retrying "Get Mail" usually succeeds in getting an
updated token but sometimes it takes 3-4 tries before it works.
I tracked the problem down to the glib function g_regex_match failing whenever
the google server returns non-ascii characters in its response ("\247" in the
case I debugged, but I've seen other values), even though that character is
near the end and nowhere close to the strings being matched. I confirmed this
with a test program and also confirmed a workaround.
I have no idea what the ideal fix is, but my workaround is to use G_REGEX_RAW
on all 3 of the g_regex_new calls in oauth2.c:
- regex = g_regex_new ("\"access_token\": ?\"(.*?)\",?", 0, 0, NULL);
+ regex = g_regex_new ("\"access_token\": ?\"(.*?)\",?", G_REGEX_RAW, 0, NULL);
- regex = g_regex_new ("\"expires_in\": ?([0-9]*),?", 0, 0, NULL);
+ regex = g_regex_new ("\"expires_in\": ?([0-9]*),?", G_REGEX_RAW, 0, NULL);
- regex = g_regex_new ("\"refresh_token\": ?\"(.*?)\",?", 0, 0, NULL);
+ regex = g_regex_new ("\"refresh_token\": ?\"(.*?)\",?", G_REGEX_RAW, 0, NULL);
More information about the Users
mailing list