File: uri_escape.t

package info (click to toggle)
libfile-desktopentry-perl 0.22-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 196 kB
  • sloc: perl: 434; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 835 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use strict;
use warnings;
use Test::More;
use File::DesktopEntry;

use utf8;

plan skip_all => "Windows"
  if $^O eq 'MSWin32';

my $buffer = <<EOF;
[Desktop Entry]
Name=Foo!
Type=Application
EOF

my $entry = File::DesktopEntry->new_from_data($buffer);

# Test escaping reserved and unicode characters
$entry->set(Exec => q#/bin/foo %U#);

my @exec = $entry->parse_Exec("/home/#=& €");

is_deeply(\@exec,
    ['/bin/foo', 'file:///home/%23%3D%26%20%E2%82%AC'],
    "parse_Exec works with %U - special characters");

# Test unescaping characters
$entry->set(Exec => q#/bin/foo %F#);

@exec = $entry->parse_Exec("file:///home/#=& € €",
    'file:///home/%23%3D%26%20%E2%82%AC €');

is_deeply(\@exec,
    ['/bin/foo', "/home/#=& € €", "/home/#=& € €"],
    "parse_Exec works with %F - special characters");

done_testing;