This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch bugfix/x2gogetapps in repository x2goserver. at e617a5b x2goserver/bin/x2gogetapps: respect NoDisplay and Hidden values, don't parse the full desktop file if there are non-Desktop Entries groups. This branch includes the following new commits: new e617a5b x2goserver/bin/x2gogetapps: respect NoDisplay and Hidden values, don't parse the full desktop file if there are non-Desktop Entries groups. The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. -- Alioth's /srv/git/code.x2go.org/x2goserver.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goserver.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/x2gogetapps in repository x2goserver. commit e617a5baec4b8971606bf37f5cef76c29ccd7423 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. --- debian/changelog | 3 ++ x2goserver/bin/x2gogetapps | 77 ++++++++++++++++++++++++++++---------------- 2 files changed, 53 insertions(+), 27 deletions(-) diff --git a/debian/changelog b/debian/changelog index f2f81a2..3ca102b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -150,6 +150,9 @@ x2goserver (4.1.0.0-0x2go1.1) UNRELEASED; urgency=low [ Mihai Moldovan ] * New upstream version (4.1.0.0): - Change string "X2go" to "X2Go" where appropriate. + - 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. * x2goserver.spec: - Only create session DB in x2goserver's post install script. Do use proper Requires(post) statements to make sure perl-X2Go-Server-DB and diff --git a/x2goserver/bin/x2gogetapps b/x2goserver/bin/x2gogetapps index 43a2fec..84a5779 100755 --- a/x2goserver/bin/x2gogetapps +++ b/x2goserver/bin/x2gogetapps @@ -93,24 +93,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 @@ -118,53 +121,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