Line with single quote causes parsing issues
qwertychouskie opened this issue · comments
QwertyChouskie commented
Take for example, this file:
[Desktop Entry]
Version=1.0
Name[af]=Padkaart
Name[an]=Mapas
Name[ar]=الخرائط
Name=Maps
Comment[af]='n Eenvoudige padkaart-toepassing
Comment[an]=Una aplicación simpla de mapas
Comment[ar]=تطبيق خرائط بسيط
Comment=A simple maps application
Exec=/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=gapplication --file-forwarding org.gnome.Maps launch org.gnome.Maps @@u %U @@
Icon=org.gnome.Maps
Terminal=false
Type=Application
StartupNotify=true
Categories=GNOME;GTK;Utility;
Because of the line Comment[af]='n Eenvoudige padkaart-toepassing
, if I let command = match section.get("Exec")
it will return None
. Setting option.enabled_quote
to true
or false
doesn't seem to make a difference.
QwertyChouskie commented
You're right, for some reason it wasn't compiling the changed code after I updated it. Still, it would probably be a good idea to find a way to fail more gracefully when enabled_quote = true
.
ty commented
I just ran a test with your case:
#[test]
fn issue113_string_no_quotes() {
let input = "
[Desktop Entry]
Version=1.0
Name[af]=Padkaart
Name[an]=Mapas
Name[ar]=الخرائط
Name=Maps
Comment[af]='n Eenvoudige padkaart-toepassing
Comment[an]=Una aplicación simpla de mapas
Comment[ar]=تطبيق خرائط بسيط
Comment=A simple maps application
Exec=/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=gapplication --file-forwarding org.gnome.Maps launch org.gnome.Maps @@u %U @@
Icon=org.gnome.Maps
Terminal=false
Type=Application
StartupNotify=true
Categories=GNOME;GTK;Utility;
";
let ini = Ini::load_from_str_opt(input,
ParseOption { enabled_quote: false,
..Default::default() }).unwrap();
assert_eq!(ini.get_from(Some("Desktop Entry"), "Exec"), Some("/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=gapplication --file-forwarding org.gnome.Maps launch org.gnome.Maps @@u %U @@"));
}
which worked perfectly as expected:
running 1 test
test test::issue113_string_no_quotes ... ok