This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch release/4.0.1.x in repository x2goserver. commit 86d9b3c13f7a0055f6c06023832e8aa5469ecd8d Author: Mihai Moldovan <ionic@ionic.de> Date: Wed Mar 11 21:00:36 2015 +0100 x2goserver/bin/x2gogetapps: respect NoDisplay and Hidden values, don't parse the full desktop file if there are non-Desktop Entries groups. Based on a patch submitted by Jason Alavaliant. Fixes: #812. Conflicts: debian/changelog --- debian/changelog | 6 ++++ x2goserver/bin/x2gogetapps | 77 ++++++++++++++++++++++++++++---------------- 2 files changed, 56 insertions(+), 27 deletions(-) diff --git a/debian/changelog b/debian/changelog index af70337..2508b02 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,12 @@ x2goserver (4.0.1.20-0x2go1) UNRELEASED; urgency=low - TERMINAL Session: Add support for qterminal (Lightweight terminal emulator written in Qt) + [ Mihai Moldovan ] + * New upstream version (4.0.1.20): + - x2goserver/bin/x2gogetapps: respect NoDisplay and Hidden values, don't + parse the full desktop file if there are non-Desktop Entries groups. + Based on a patch submitted by Jason Alavaliant. Fixes: #812. + -- X2Go Release Manager <git-admin@x2go.org> Tue, 24 Feb 2015 22:11:49 +0100 x2goserver (4.0.1.19-0x2go2) UNRELEASED; urgency=low diff --git a/x2goserver/bin/x2gogetapps b/x2goserver/bin/x2gogetapps index 09ba50d..c374d6e 100755 --- a/x2goserver/bin/x2gogetapps +++ b/x2goserver/bin/x2gogetapps @@ -91,24 +91,27 @@ sub findicon_ext return ""; } -sub printicon +sub geticon { my $file=shift; + my @ret; if (open(I,"<$file")) { my $buf; - print "<icon>\n"; + push(@ret, "<icon>"); while (read(I, $buf, 60*57)) { - print encode_base64($buf); + push(@ret, encode_base64($buf)); } - print "</icon>\n"; + push(@ret, "</icon>\n"); close(I); } else { - syslog ('info', "x2gogetapps:printicon - can't open file $file: $!"); + syslog ('info', "x2gogetapps:geticon - can't open file $file: $!"); } + + return @ret; } sub proc_desktop_file @@ -116,53 +119,73 @@ sub proc_desktop_file my $file=shift; if (open(F,"<$file")) { - print("<desktop>\n"); + push(@output, "<desktop>"); + my @output; + my $nodisplay = 0; my $is_desktop_entry = 0; - while(!eof(F)) + READ_FILE: while(!eof(F)) { my $line=<F>; + # Hopefully strip most whitespace and newlines surrounding $line. + chomp($line); + # Desktop Entry block search. if ( $line=~m/^\[Desktop Entry\] */ ) { $is_desktop_entry = 1; next; } + # Consume random data. if ( ! $is_desktop_entry ) { next; } + # Stop reading when seeing a non-Desktop Entry block. if ( $line=~m/^\[.*\] */ ) { $is_desktop_entry = 0; - next; + last READ_FILE; + } + # Breaking out when finding NoDisplay=true or Hidden=true. + # Do not use \s here as newlines are not allowed within key-value sets. + # Generally, we're reading lines anyway and a newline can't possibly be part of + # a line, as lines are split on newlines, but play it safe still. + if ( $line=~m/^NoDisplay[ \t]*?=[ \t]*?true/ || $line=~m/^Hidden[ \t]*?=[ \t]*?true/ ) + { + $nodisplay = 1; + last READ_FILE; } - if( $line=~m/^Categories/i || $line=~m/^Name/i || $line=~m/^Terminal/i || $line=~m/^Comment/i || $line=~m/^Exec/i) + if ( $line=~m/^Categories/i || $line=~m/^Name/i || $line=~m/^Terminal/i || $line=~m/^Comment/i || $line=~m/^Exec/i) { - print $line; + push(@output, $line); } - if( $line =~ m/^Icon/ ) + if ( $line =~ m/^Icon/ ) { my $icon=$line; - $icon =~ s/Icon=//; - chop($icon); - #$line is absolute path - if($icon =~ m/\//) - { - $icon=$icon; - } - #$line have format ext. - elsif ($line =~ m/\./) + $icon =~ s/Icon[ \t]*?=//; + #$line is not absolute path + if(!($icon =~ m/\//)) { - $icon=findicon_ext($icon); + #$line have format ext. + if ($line =~ m/\./) + { + $icon=findicon_ext($icon); + } + else + { + $icon=findicon($icon); + } } - else - { - $icon=findicon($icon); - } - printicon($icon); + @output = (@output, geticon($icon)); } } close (F); - print("</desktop>\n"); + push(@output, "</desktop>\n"); + + # Print out parsed entry if it's not hidden or marked NoDisplay. + if (! $nodisplay) + { + print join("\n", @output); + } } else { -- Alioth's /srv/git/code.x2go.org/x2goserver.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goserver.git