Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
1 use File::Spec;
3 my(@chunks, @list, $entry, $main_cats, $spacing);
4 @list = ('conf', 'perf');
5 foreach $entry (@list) {
6 $main_cats .= " <rdf:li><rdf:Description about=\"urn:x-buster:$entry\" nc:dir=\"$entry\" /></rdf:li>\n";
7 go_in($entry, '', $entry);
8 }
9 if ($ARGV[0]) {
10 open OUTPUT, ">$ARGV[0]";
11 }
12 else {
13 open OUTPUT, ">xalan.rdf";
14 };
15 select(OUTPUT);
16 print '<?xml version="1.0"?>
18 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
19 xmlns:nc="http://home.netscape.com/NC-rdf#">
20 <rdf:Seq about="urn:root">
21 ' . $main_cats . ' </rdf:Seq>
22 ';
23 print join('',@chunks);
24 print '</rdf:RDF>
25 ';
26 exit 0;
28 sub go_in {
29 my($current, $about, $cat) = @_;
30 my (@list, $entry, @subdirs, @files, @purps, $rdf);
31 chdir $current;
32 @list = <*>;
34 LOOP: foreach $entry (@list) {
35 next LOOP if $entry=~/^CVS$/;
36 if (! -d $entry) {
37 if ($entry=~/^($current.*)\.xsl$/) {
38 local $source = $entry;
39 $source=~s/xsl$/xml/;
40 next LOOP if ! -f $source;
41 $entry=~/^($current.*)\.xsl$/;
42 push(@files, $1);
43 local ($purp, $purp_open);
44 open STYLE, $entry;
45 $purp_open = 0;
46 while (<STYLE>) {
47 if (/<!--\s+purpose: (.+)\s*-->/i) {
48 $purp .= $1;
49 }
50 elsif (/<!--\s+purpose: (.+)\s*$/i) {
51 $purp_open = 1;
52 $purp .= $1;
53 }
54 elsif ($purp_open) {
55 if (/\s*(\s.+)\s*-->/) {
56 $purp_open = 0;
57 $purp .= $1;
58 }
59 elsif (/\s*(\s.+)\s*$/) {
60 $purp .= $1;
61 }
62 }
63 }
64 $purp=~s/"/'/g; $purp=~s/&/&/g; $purp=~s/</</g;
65 $purp=~s/\r/ /g; $purp=~s/\s\s/ /g; $purp=~s/\s$//g;
66 push(@purps, $purp);
67 }
68 }
69 else {
70 push(@subdirs, $entry);
71 }
72 }
74 if (@subdirs > 0 || @files > 0) {
75 my $topic = $about.$current; $topic=~s/\///g;
76 $rdf = ' <rdf:Seq about="urn:x-buster:'.$topic."\">\n";
77 foreach $entry (@subdirs) {
78 if (go_in($entry, $about.$current.'/', $cat)) {
79 my $id = 'urn:x-buster:'.$about.$current.$entry; $id=~s/\///g;
80 $rdf .= " <rdf:li><rdf:Description about=\"$id\" nc:dir=\"$entry\" /></rdf:li>\n";
81 }
82 }
83 for (my $i=0; $i < @files; $i++) {
84 my $uri = $about.$current.'/'.$files[$i];
85 $uri=~s/[^\/]+\///;
86 my $id = $uri; $id=~s/\///g;
87 $rdf .= " <rdf:li><rdf:Description about=\"urn:x-buster:$files[$i]\" nc:name=\"$files[$i]\" nc:purp=\"$purps[$i]\" nc:path=\"$uri\" nc:category=\"$cat\" /></rdf:li>\n";
88 }
89 $rdf .= " </rdf:Seq>\n";
90 push(@chunks, $rdf);
91 }
93 chdir File::Spec->updir;
94 return (@subdirs > 0 || @files > 0);
95 }