Commit 4bd1de9f authored by Frédéric Buclin's avatar Frédéric Buclin

Bug 398546 - config.cgi using the RDF format can generate a pretty large file

r=dkl
parent 437d7e21
...@@ -42,3 +42,9 @@ Options -Indexes ...@@ -42,3 +42,9 @@ Options -Indexes
RewriteOptions inherit RewriteOptions inherit
RewriteRule ^rest/(.*)$ rest.cgi/$1 [NE] RewriteRule ^rest/(.*)$ rest.cgi/$1 [NE]
</IfModule> </IfModule>
# config.cgi using the RDF format can generate a pretty large file (several MB).
# The XML format of bug reports can be quite large too.
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/xml application/rdf+xml
</IfModule>
...@@ -139,6 +139,9 @@ sub display_data { ...@@ -139,6 +139,9 @@ sub display_data {
$template->process($format->{'template'}, $vars, \$output) $template->process($format->{'template'}, $vars, \$output)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
# Remove leading whitespaces, to save some bandwidth.
$output =~ s/^\s+(?=<)//gm if $format->{'ctype'} =~ /rdf/;
# Wide characters cause md5_base64() to die. # Wide characters cause md5_base64() to die.
my $digest_data = $output; my $digest_data = $output;
utf8::encode($digest_data) if utf8::is_utf8($digest_data); utf8::encode($digest_data) if utf8::is_utf8($digest_data);
......
...@@ -130,10 +130,11 @@ ...@@ -130,10 +130,11 @@
<bz:products> <bz:products>
<Seq> <Seq>
[% FOREACH product = products %] [% FOREACH product = products %]
[% uri_product_name = product.name FILTER uri %]
<li> <li>
<bz:product rdf:about="[% escaped_urlbase %]product.cgi?name=[% product.name FILTER uri %]"> <bz:product rdf:about="[% escaped_urlbase %]product.cgi?name=[% uri_product_name %]">
<bz:name>[% product.name FILTER html %]</bz:name> <bz:name>[% product.name FILTER html %]</bz:name>
<bz:allows_unconfirmed>[% product.allows_unconfirmed FILTER html %]</bz:allows_unconfirmed> <bz:allows_unconfirmed>[% product.allows_unconfirmed FILTER none %]</bz:allows_unconfirmed>
[% IF Param('useclassification') %] [% IF Param('useclassification') %]
<bz:classification>[% class_names.${product.classification_id}.name FILTER html %]</bz:classification> <bz:classification>[% class_names.${product.classification_id}.name FILTER html %]</bz:classification>
[% END %] [% END %]
...@@ -141,7 +142,7 @@ ...@@ -141,7 +142,7 @@
<Seq> <Seq>
[% FOREACH comp = product.components %] [% FOREACH comp = product.components %]
<li resource="[% escaped_urlbase %]component.cgi?name=[% comp.name FILTER uri <li resource="[% escaped_urlbase %]component.cgi?name=[% comp.name FILTER uri
%]&amp;product=[% product.name FILTER uri %]"/> %]&amp;product=[% uri_product_name %]"/>
[% END %] [% END %]
</Seq> </Seq>
</bz:components> </bz:components>
...@@ -150,7 +151,7 @@ ...@@ -150,7 +151,7 @@
<Seq> <Seq>
[% FOREACH version = product.versions %] [% FOREACH version = product.versions %]
<li resource="[% escaped_urlbase %]version.cgi?name=[% version.name FILTER uri <li resource="[% escaped_urlbase %]version.cgi?name=[% version.name FILTER uri
%]&amp;product=[% product.name FILTER uri %]"/> %]&amp;product=[% uri_product_name %]"/>
[% END %] [% END %]
</Seq> </Seq>
</bz:versions> </bz:versions>
...@@ -160,12 +161,11 @@ ...@@ -160,12 +161,11 @@
<Seq> <Seq>
[% FOREACH milestone = product.milestones %] [% FOREACH milestone = product.milestones %]
<li resource="[% escaped_urlbase %]milestone.cgi?name=[% milestone.name FILTER uri <li resource="[% escaped_urlbase %]milestone.cgi?name=[% milestone.name FILTER uri
%]&amp;product=[% product.name FILTER uri %]"/> %]&amp;product=[% uri_product_name %]"/>
[% END %] [% END %]
</Seq> </Seq>
</bz:target_milestones> </bz:target_milestones>
[% END %] [% END %]
</bz:product> </bz:product>
</li> </li>
[% END %] [% END %]
...@@ -176,12 +176,13 @@ ...@@ -176,12 +176,13 @@
<bz:components> <bz:components>
<Seq> <Seq>
[% FOREACH product = products %] [% FOREACH product = products %]
[% uri_product_name = product.name FILTER uri %]
[% FOREACH comp = product.components %] [% FOREACH comp = product.components %]
<li> <li>
<bz:component rdf:about="[% escaped_urlbase %]component.cgi?name=[% comp.name FILTER uri <bz:component rdf:about="[% escaped_urlbase %]component.cgi?name=[% comp.name FILTER uri
%]&amp;product=[% product.name FILTER uri %]"> %]&amp;product=[% uri_product_name %]">
<bz:name>[% comp.name FILTER html %]</bz:name> <bz:name>[% comp.name FILTER html %]</bz:name>
<bz:is_active>[% comp.is_active FILTER html %]</bz:is_active> <bz:is_active>[% comp.is_active FILTER none %]</bz:is_active>
[% IF show_flags %] [% IF show_flags %]
<bz:flag_types> <bz:flag_types>
<Seq> <Seq>
...@@ -189,7 +190,7 @@ ...@@ -189,7 +190,7 @@
[% FOREACH flag_type = flag_types %] [% FOREACH flag_type = flag_types %]
[% NEXT UNLESS flag_type.is_active %] [% NEXT UNLESS flag_type.is_active %]
[% all_visible_flag_types.${flag_type.id} = flag_type %] [% all_visible_flag_types.${flag_type.id} = flag_type %]
<li resource="[% escaped_urlbase %]flag.cgi?id=[% flag_type.id FILTER uri <li resource="[% escaped_urlbase %]flag.cgi?id=[% flag_type.id
%]&amp;name=[% flag_type.name FILTER uri %]" /> %]&amp;name=[% flag_type.name FILTER uri %]" />
[% END %] [% END %]
</Seq> </Seq>
...@@ -205,12 +206,13 @@ ...@@ -205,12 +206,13 @@
<bz:versions> <bz:versions>
<Seq> <Seq>
[% FOREACH product = products %] [% FOREACH product = products %]
[% uri_product_name = product.name FILTER uri %]
[% FOREACH version = product.versions %] [% FOREACH version = product.versions %]
<li> <li>
<bz:version rdf:about="[% escaped_urlbase %]version.cgi?name=[% version.name FILTER uri <bz:version rdf:about="[% escaped_urlbase %]version.cgi?name=[% version.name FILTER uri
%]&amp;product=[% product.name FILTER uri %]"> %]&amp;product=[% uri_product_name %]">
<bz:name>[% version.name FILTER html %]</bz:name> <bz:name>[% version.name FILTER html %]</bz:name>
<bz:is_active>[% version.is_active FILTER html %]</bz:is_active> <bz:is_active>[% version.is_active FILTER none %]</bz:is_active>
</bz:version> </bz:version>
</li> </li>
[% END %] [% END %]
...@@ -222,12 +224,13 @@ ...@@ -222,12 +224,13 @@
<bz:target_milestones> <bz:target_milestones>
<Seq> <Seq>
[% FOREACH product = products %] [% FOREACH product = products %]
[% uri_product_name = product.name FILTER uri %]
[% FOREACH milestone = product.milestones %] [% FOREACH milestone = product.milestones %]
<li> <li>
<bz:target_milestone rdf:about="[% escaped_urlbase %]milestone.cgi?name=[% milestone.name FILTER uri <bz:target_milestone rdf:about="[% escaped_urlbase %]milestone.cgi?name=[% milestone.name FILTER uri
%]&amp;product=[% product.name FILTER uri %]"> %]&amp;product=[% uri_product_name %]">
<bz:name>[% milestone.name FILTER html %]</bz:name> <bz:name>[% milestone.name FILTER html %]</bz:name>
<bz:is_active>[% milestone.is_active FILTER html %]</bz:is_active> <bz:is_active>[% milestone.is_active FILTER none %]</bz:is_active>
</bz:target_milestone> </bz:target_milestone>
</li> </li>
[% END %] [% END %]
...@@ -241,15 +244,15 @@ ...@@ -241,15 +244,15 @@
<Seq> <Seq>
[% FOREACH flag_type = all_visible_flag_types.values.sort('name') %] [% FOREACH flag_type = all_visible_flag_types.values.sort('name') %]
<li> <li>
<bz:flag_type rdf:about="[% escaped_urlbase %]flag.cgi?id=[% flag_type.id FILTER uri <bz:flag_type rdf:about="[% escaped_urlbase %]flag.cgi?id=[% flag_type.id
%]&amp;name=[% flag_type.name FILTER uri %]"> %]&amp;name=[% flag_type.name FILTER uri %]">
<bz:id>[% flag_type.id FILTER html %]</bz:id> <bz:id>[% flag_type.id %]</bz:id>
<bz:name>[% flag_type.name FILTER html %]</bz:name> <bz:name>[% flag_type.name FILTER html %]</bz:name>
<bz:description>[% flag_type.description FILTER html %]</bz:description> <bz:description>[% flag_type.description FILTER html %]</bz:description>
<bz:type>[% flag_type.target_type FILTER html %]</bz:type> <bz:type>[% flag_type.target_type FILTER html %]</bz:type>
<bz:requestable>[% flag_type.is_requestable FILTER html %]</bz:requestable> <bz:requestable>[% flag_type.is_requestable FILTER none %]</bz:requestable>
<bz:specifically_requestable>[% flag_type.is_requesteeble FILTER html %]</bz:specifically_requestable> <bz:specifically_requestable>[% flag_type.is_requesteeble FILTER none %]</bz:specifically_requestable>
<bz:multiplicable>[% flag_type.is_multiplicable FILTER html %]</bz:multiplicable> <bz:multiplicable>[% flag_type.is_multiplicable FILTER none %]</bz:multiplicable>
[% IF user.in_group("editcomponents") %] [% IF user.in_group("editcomponents") %]
<bz:grant_group>[% flag_type.grant_group.name FILTER html %]</bz:grant_group> <bz:grant_group>[% flag_type.grant_group.name FILTER html %]</bz:grant_group>
<bz:request_group>[% flag_type.request_group.name FILTER html %]</bz:request_group> <bz:request_group>[% flag_type.request_group.name FILTER html %]</bz:request_group>
...@@ -271,12 +274,12 @@ ...@@ -271,12 +274,12 @@
<bz:description>[% (field_descs.${item.name} OR item.description) FILTER html %]</bz:description> <bz:description>[% (field_descs.${item.name} OR item.description) FILTER html %]</bz:description>
[%-# These values are meaningful for custom fields only. %] [%-# These values are meaningful for custom fields only. %]
[% IF item.custom %] [% IF item.custom %]
<bz:type>[% item.type FILTER html %]</bz:type> <bz:type>[% item.type FILTER none %]</bz:type>
<bz:type_desc>[% field_types.${item.type} FILTER html %]</bz:type_desc> <bz:type_desc>[% field_types.${item.type} FILTER html %]</bz:type_desc>
<bz:enter_bug>[% item.enter_bug FILTER html %]</bz:enter_bug> <bz:enter_bug>[% item.enter_bug FILTER none %]</bz:enter_bug>
[% END %] [% END %]
[% IF item.is_active.defined %] [% IF item.is_active.defined %]
<bz:is_active>[% item.is_active FILTER html %]</bz:is_active> <bz:is_active>[% item.is_active FILTER none %]</bz:is_active>
[% END %] [% END %]
</bz:field> </bz:field>
</li> </li>
......
...@@ -448,6 +448,8 @@ ...@@ -448,6 +448,8 @@
'config.rdf.tmpl' => [ 'config.rdf.tmpl' => [
'escaped_urlbase', 'escaped_urlbase',
'uri_product_name',
'flag_type.id'
], ],
); );
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment