Problem/Motivation
We have a site with over 60 languages, many using non-ascii chars in their paths. Any path using non-ascii chars causes an error when we try to purge
Steps to reproduce
Create some content with non ascii path , etc 'hostname.com/stories/пицца'
Paste 'stories/пицца' into the 'Paths/URLs/CPCodes' text box
You'll get an error "There was an error clearing the cache. Check logs for further detail."
Looking at logs you'll see:
Jun 10 02:25:27 local drupal: POST /ccu/v3/invalidate/url/staging HTTP/1.1\x0d
Jun 10 02:25:27 local drupal: Content-Length: 85\x0d
Jun 10 02:25:27 local drupal: User-Agent: Akamai-Open-Edgegrid-PHP/1.0.0 GuzzleHttp/6.5.5 curl/7.47.0 PHP/7.3.27-7+ubuntu16.04.1+deb.sury.org+1\x0d
Jun 10 02:25:27 local drupal: Content-Type: application/json\x0d
Jun 10 02:25:27 local drupal: Host: xxxxxxxxxxxf.purge.akamaiapis.net\x0d
Jun 10 02:25:27 local drupal: \x0d
Jun 10 02:25:27 local drupal: @"objects":["https:\/\/www.xxxxxx.org\/stories\/\u043f\u0438\u0446\u0446\u0430"]
Jun 10 02:25:27 local drupal:
Jun 10 02:25:27 local drupal: https://local.xxx.org|1623291927|akamai|192.168.3.1|https://local.xxxx.org/admin/config/akamai/cache-clear?XDEBUG_SESSION_START=1|https://local.xxxx.org/admin/config/akamai/cache-clear|1||httpStatus: 400
Jun 10 02:25:27 local drupal: detail: Invalid or malformed URL 'https://www.xxxx.org/stories/пицца': contains non-ASCII character 'п' (CYRILLIC SMALL LETTER PE)
Jun 10 02:25:27 local drupal: supportId: eius-4jxLZeiuwRNN2n15X9rLae
Jun 10 02:25:27 local drupal: title: bad URL
Jun 10 02:25:27 local drupal: describedBy: https://developer.akamai.com/api/core_features/fast_purge/v3.html#httpcodes
Proposed resolution
url-encode non ascii characters
Comments
Comment #2
luca_loguercio commentedAttaching a patch that I think should work, though still testing
Comment #3
luca_loguercio commentedComment #4
WidgetsBurritos commentedComment #5
WidgetsBurritos commentedThis solution doesn't seem correct to me. You are replacing the $url value, not inside the loop, but after the loop is done where $url is ever getting used. In best case, it will only update that last url in the list (although I'm admittedly unsure about variable scope when using & references, so I'm not sure if it will even do that off the top of my head).
Additionally this only ever impacts ::normalizeUrls(), but there are some other cases where ::normalizeUrl() (without the trailing "s") is used (e.g.,
CacheControlForm::submitForm()), and it doesn't seem to resolve the issue there either. I think it would be better if this normalization occurred in ::normalizeUrl() instead.Comment #6
smustgrave commentedSince there's been no follow up to #5 in 5 years going to close out. If still an issue in 6.0.x please re-open.