Thanks to Claude Peroz for the draft patch. (cherry picked from commit f5e4a699ca0f58818acbdf9081164060cee910fa)