[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#35785: ‘string->uri’ is locale-dependent and breaks in ‘sv_SE’
From: |
Ludovic Courtès |
Subject: |
bug#35785: ‘string->uri’ is locale-dependent and breaks in ‘sv_SE’ |
Date: |
Tue, 04 Jun 2019 09:42:55 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
Hello,
Timothy Sample <address@hidden> skribis:
>>> From 7b02be4c050c7b17a0e2685e8e453295f798c360 Mon Sep 17 00:00:00 2001
>>> From: Timothy Sample <address@hidden>
>>> Date: Sun, 2 Jun 2019 14:41:20 -0400
>>> Subject: [PATCH] Make URI handling locale independent.
>>>
>>> Fixes <https://bugs.gnu.org/35785>.
>>>
>>> * module/web/uri.scm (digits, hex-digits, letters): New variables.
>>> (ipv4-regexp, ipv6-regexp, domain-label-regexp, top-label-regexp,
>>> userinfo-pat, host-pat, ipv6-host-pat, port-pat, scheme-pat): Explicitly
>>> list each character instead of using character ranges.
>>> * test-suite/tests/web-uri.test: Add corresponding tests.
>>
>> [...]
>>
>>> + (pass-if "http://www.example.com (sv_SE)"
>>> + (dynamic-wind
>>> + (lambda () #t)
>>> + (lambda ()
>>> + (with-locale "sv_SE.utf8"
>>> + (reload-module (resolve-module '(web uri)))
>>> + (uri=? (string->uri "http://www.example.com")
>>> + #:scheme 'http #:host "www.example.com" #:path "")))
>>
>> Aren’t ‘reload-module’ calls a leftover that can now be removed (also in
>> the other test)?
>
> I needed to reload the modules like that to make the tests fail without
> the patch and pass with it. My understanding is that the bug happens
> at regex compile time, which happens when the module is loaded. If I
> don’t reload the module, the old URI code passes the tests, since the
> regexes were compiled with a locale that does not trigger the bug. It’s
> a little wacky, sure, but it was the best idea I could come up with.
Oooh, I see. Could you add a comment to explain this? Then we’re done.
>> For the sv_SE test, what about taking a host name with a ‘w’, since
>> that’s the use case that allowed us to uncover this bug?
>
> I thought I was being clever by using a “www” hostname, but apparently
> it’s so normalized as to be invisible! Feel free to change it to
> something more obvious like “w.com” or whatever.
Silly me, I guess I need new glasses. :-)
Thanks!
Ludo’.