]> git.openstreetmap.org Git - rails.git/commitdiff
Use _html suffix to avoid using raw when displaying translated strings
authorAndy Allan <git@gravitystorm.co.uk>
Thu, 2 Jan 2020 16:13:41 +0000 (17:13 +0100)
committerAndy Allan <git@gravitystorm.co.uk>
Thu, 2 Jan 2020 16:13:41 +0000 (17:13 +0100)
This is safer than raw, since any user input is still escaped.

app/views/browse/_containing_relation.html.erb
app/views/browse/_relation_member.html.erb
app/views/browse/_way.html.erb
app/views/browse/feature.html.erb
app/views/geocoder/search.html.erb
app/views/site/copyright.html.erb
config/locales/en.yml

index b3cb90cec2aa4a7d05b705c1c2745b6f59237a23..ba05c1fe427471e805464e210fe4719df3921746 100644 (file)
@@ -1,7 +1,7 @@
 <li><%= linked_name = link_to h(printable_name(containing_relation.relation)), :action => "relation", :id => containing_relation.relation.id.to_s
         if containing_relation.member_role.blank?
 <li><%= linked_name = link_to h(printable_name(containing_relation.relation)), :action => "relation", :id => containing_relation.relation.id.to_s
         if containing_relation.member_role.blank?
-          raw t ".entry", :relation_name => linked_name
+          t ".entry_html", :relation_name => linked_name
         else
         else
-          raw t ".entry_role", :relation_name => linked_name, :relation_role => h(containing_relation.member_role)
+          t ".entry_role_html", :relation_name => linked_name, :relation_role => h(containing_relation.member_role)
         end %>
 </li>
         end %>
 </li>
index bb37bdf210a5c7ee89ee6c792e9e01a37af474c2..fe0f363574e0e0904023d4bc1c91f08aa617b16d 100644 (file)
@@ -3,8 +3,8 @@
    type_str = t ".type." + relation_member.member_type.downcase %>
 <li class="<%= member_class %>">
   <%= if relation_member.member_role.blank?
    type_str = t ".type." + relation_member.member_type.downcase %>
 <li class="<%= member_class %>">
   <%= if relation_member.member_role.blank?
-        raw t ".entry", :type => type_str, :name => linked_name
+        t ".entry_html", :type => type_str, :name => linked_name
       else
       else
-        raw t ".entry_role", :type => type_str, :name => linked_name, :role => h(relation_member.member_role)
+        t ".entry_role_html", :type => type_str, :name => linked_name, :role => h(relation_member.member_role)
       end %>
 </li>
       end %>
 </li>
index ed206c59bcc7399f803a2bca50e1882ccff569c1..5560344a86e9dd4b733aa4bd68436a1803abfac4 100644 (file)
@@ -25,7 +25,7 @@
             <%= link_to printable_name(wn.node), { :action => "node", :id => wn.node_id.to_s }, { :class => link_class("node", wn.node), :title => link_title(wn.node), :rel => link_follow(wn.node) } %>
             <% related_ways = wn.node.ways.reject { |w| w.id == wn.way_id } %>
             <% if related_ways.size > 0 then %>
             <%= link_to printable_name(wn.node), { :action => "node", :id => wn.node_id.to_s }, { :class => link_class("node", wn.node), :title => link_title(wn.node), :rel => link_follow(wn.node) } %>
             <% related_ways = wn.node.ways.reject { |w| w.id == wn.way_id } %>
             <% if related_ways.size > 0 then %>
-              (<%= raw t ".also_part_of", :count => related_ways.size, :related_ways => related_ways.map { |w| link_to(printable_name(w), { :action => "way", :id => w.id.to_s }, { :class => link_class("way", w), :title => link_title(w) }) }.to_sentence %>)
+              (<%= t ".also_part_of_html", :count => related_ways.size, :related_ways => to_sentence(related_ways.map { |w| link_to(printable_name(w), { :action => "way", :id => w.id.to_s }, { :class => link_class("way", w), :title => link_title(w) }) }) %>)
             <% end %>
           </li>
         <% end %>
             <% end %>
           </li>
         <% end %>
index 6c94b0a9dfd50aa8dab39c5ec33611c29c4abd2e..7dfccb29053ba60f51eebd77be9351b5dfb1c0ef 100644 (file)
@@ -2,7 +2,7 @@
 
 <h2>
   <a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
 
 <h2>
   <a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
-  <%= raw t("browse.#{@type}.title", :name => printable_name(@feature)) %>
+  <%= t("browse.#{@type}.title_html", :name => printable_name(@feature)) %>
 </h2>
 
 <%= render :partial => @type, :object => @feature %>
 </h2>
 
 <%= render :partial => @type, :object => @feature %>
index 3eb9561a2d2105a7d3ec0443de412f3739532dc6..13144d568eda6306a3f0345278669f9c2fa3f6a0 100644 (file)
@@ -5,7 +5,7 @@
     <%= t("site.sidebar.search_results") %>
 </h2>
 <% @sources.each do |source| %>
     <%= t("site.sidebar.search_results") %>
 </h2>
 <% @sources.each do |source| %>
-  <h4 class="inner12"><%= raw(t(".title.#{source}")) %></h4>
+  <h4 class="inner12"><%= t(".title.#{source}_html") %></h4>
   <div class="search_results_entry" data-href="<%= url_for @params.merge(:action => "search_#{source}") %>">
     <%= image_tag "searching.gif", :class => "loader" %>
   </div>
   <div class="search_results_entry" data-href="<%= url_for @params.merge(:action => "search_#{source}") %>">
     <%= image_tag "searching.gif", :class => "loader" %>
   </div>
index feec81c82172053f7921bbd8d537772c58647d1d..c6a0348df001f658ab014e6d3c0d27fbda00a92d 100644 (file)
@@ -6,14 +6,14 @@
       <%= tag.h1 :lang => @locale, :dir => t("html.dir", :locale => @locale) do %>
         <h1><%= t ".native.title" %></h1>
         <p>
       <%= tag.h1 :lang => @locale, :dir => t("html.dir", :locale => @locale) do %>
         <h1><%= t ".native.title" %></h1>
         <p>
-          <%= raw t ".native.text",
-                    :native_link => link_to(t(".native.native_link"),
-                                            :controller => "site",
-                                            :action => "copyright",
-                                            :copyright_locale => nil),
-                    :mapping_link => link_to(t(".native.mapping_link"),
-                                             :controller => "site",
-                                             :action => "index") %>
+          <%= t ".native.html",
+              :native_link => link_to(t(".native.native_link"),
+                                      :controller => "site",
+                                      :action => "copyright",
+                                      :copyright_locale => nil),
+              :mapping_link => link_to(t(".native.mapping_link"),
+                                       :controller => "site",
+                                       :action => "index") %>
         </p>
       <% end %>
       <hr />
         </p>
       <% end %>
       <hr />
       <% if t(".legal_babble", :locale => @locale) != t(".legal_babble", :locale => :en) %>
         <h1><%= t ".foreign.title" %></h1>
         <p>
       <% if t(".legal_babble", :locale => @locale) != t(".legal_babble", :locale => :en) %>
         <h1><%= t ".foreign.title" %></h1>
         <p>
-          <%= raw t ".foreign.text",
-                    :english_original_link => link_to(t(".foreign.english_link"),
-                                                      :controller => "site",
-                                                      :action => "copyright",
-                                                      :copyright_locale => "en") %>
+          <%= t ".foreign.html",
+              :english_original_link => link_to(t(".foreign.english_link"),
+                                                :controller => "site",
+                                                :action => "copyright",
+                                                :copyright_locale => "en") %>
         </p>
       <% end %>
       <hr />
         </p>
       <% end %>
       <hr />
index 9e2e6dbb7354c581a1d4d6d9f1d2e210eecb7d41..31531a656e480943ed02b8e466bea2ca7e41d894 100644 (file)
@@ -221,29 +221,29 @@ en:
       discussion: Discussion
       still_open: "Changeset still open - discussion will open once the changeset is closed."
     node:
       discussion: Discussion
       still_open: "Changeset still open - discussion will open once the changeset is closed."
     node:
-      title: "Node: %{name}"
+      title_html: "Node: %{name}"
       history_title: "Node History: %{name}"
     way:
       history_title: "Node History: %{name}"
     way:
-      title: "Way: %{name}"
+      title_html: "Way: %{name}"
       history_title: "Way History: %{name}"
       nodes: "Nodes"
       history_title: "Way History: %{name}"
       nodes: "Nodes"
-      also_part_of:
+      also_part_of_html:
         one: "part of way %{related_ways}"
         other: "part of ways %{related_ways}"
     relation:
         one: "part of way %{related_ways}"
         other: "part of ways %{related_ways}"
     relation:
-      title: "Relation: %{name}"
+      title_html: "Relation: %{name}"
       history_title: "Relation History: %{name}"
       members: "Members"
     relation_member:
       history_title: "Relation History: %{name}"
       members: "Members"
     relation_member:
-      entry: "%{type} %{name}"
-      entry_role: "%{type} %{name} as %{role}"
+      entry_html: "%{type} %{name}"
+      entry_role_html: "%{type} %{name} as %{role}"
       type:
         node: "Node"
         way: "Way"
         relation: "Relation"
     containing_relation:
       type:
         node: "Node"
         way: "Way"
         relation: "Relation"
     containing_relation:
-      entry: "Relation %{relation_name}"
-      entry_role: "Relation %{relation_name} (as %{relation_role})"
+      entry_html: "Relation %{relation_name}"
+      entry_role_html: "Relation %{relation_name} (as %{relation_role})"
     not_found:
       sorry: "Sorry, %{type} #%{id} could not be found."
       type:
     not_found:
       sorry: "Sorry, %{type} #%{id} could not be found."
       type:
@@ -422,12 +422,12 @@ en:
   geocoder:
     search:
       title:
   geocoder:
     search:
       title:
-        latlon: 'Results from <a href="https://openstreetmap.org/">Internal</a>'
-        ca_postcode: 'Results from <a href="https://geocoder.ca/">Geocoder.CA</a>'
-        osm_nominatim: 'Results from <a href="https://nominatim.openstreetmap.org/">OpenStreetMap Nominatim</a>'
-        geonames: 'Results from <a href="http://www.geonames.org/">GeoNames</a>'
-        osm_nominatim_reverse: 'Results from <a href="https://nominatim.openstreetmap.org/">OpenStreetMap Nominatim</a>'
-        geonames_reverse: 'Results from <a href="http://www.geonames.org/">GeoNames</a>'
+        latlon_html: 'Results from <a href="https://openstreetmap.org/">Internal</a>'
+        ca_postcode_html: 'Results from <a href="https://geocoder.ca/">Geocoder.CA</a>'
+        osm_nominatim_html: 'Results from <a href="https://nominatim.openstreetmap.org/">OpenStreetMap Nominatim</a>'
+        geonames_html: 'Results from <a href="http://www.geonames.org/">GeoNames</a>'
+        osm_nominatim_reverse_html: 'Results from <a href="https://nominatim.openstreetmap.org/">OpenStreetMap Nominatim</a>'
+        geonames_reverse_html: 'Results from <a href="http://www.geonames.org/">GeoNames</a>'
     search_osm_nominatim:
       prefix_format: "%{name}"
       prefix:
     search_osm_nominatim:
       prefix_format: "%{name}"
       prefix:
@@ -1373,11 +1373,11 @@ en:
     copyright:
       foreign:
         title: About this translation
     copyright:
       foreign:
         title: About this translation
-        text: In the event of a conflict between this translated page and %{english_original_link}, the English page shall take precedence
+        html: In the event of a conflict between this translated page and %{english_original_link}, the English page shall take precedence
         english_link: the English original
       native:
         title: About this page
         english_link: the English original
       native:
         title: About this page
-        text: You are viewing the English version of the copyright page. You can go back to the %{native_link} of this page or you can stop reading about copyright and %{mapping_link}.
+        html: You are viewing the English version of the copyright page. You can go back to the %{native_link} of this page or you can stop reading about copyright and %{mapping_link}.
         native_link: THIS_LANGUAGE_NAME_HERE version
         mapping_link: start mapping
       legal_babble:
         native_link: THIS_LANGUAGE_NAME_HERE version
         mapping_link: start mapping
       legal_babble: