Skip to content

Commit 73e8f2d

Browse files
committed
Fix double-escaping
1 parent 0e243f7 commit 73e8f2d

10 files changed

Lines changed: 44 additions & 20 deletions

File tree

decidim-assemblies/app/helpers/decidim/assemblies/assemblies_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def assembly_nav_items(participatory_space)
3030
)
3131
] + components.map do |component|
3232
{
33-
name: decidim_escape_translated(component.name),
33+
name: component.name,
3434
url: main_component_path(component),
3535
active: is_active_link?(main_component_path(component), :inclusive)
3636
}

decidim-assemblies/spec/shared/manage_assembly_components_examples.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@
201201

202202
it "hides the component from the menu" do
203203
visit decidim_assemblies.assembly_path(assembly, locale: I18n.locale)
204-
expect(page).to have_content decidim_escape_translated(component.name)
204+
expect(page).to have_content translated(component.name)
205+
expect(page.html).to include decidim_escape_translated(component.name).gsub(""", "\"")
205206

206207
visit decidim_admin_assemblies.components_path(assembly)
207208

@@ -216,7 +217,7 @@
216217
end
217218

218219
visit decidim_assemblies.assembly_path(assembly, locale: I18n.locale)
219-
expect(page).to have_no_content decidim_escape_translated(component.name)
220+
expect(page).to have_no_content translated(component.name)
220221
end
221222
end
222223

decidim-assemblies/spec/system/assemblies_spec.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,9 @@
252252

253253
it "shows the components" do
254254
within ".participatory-space__nav-container" do
255-
expect(page).to have_content(decidim_escape_translated(proposals_component.name))
256-
expect(page).to have_no_content(decidim_escape_translated(meetings_component.name))
255+
expect(page).to have_content(translated(proposals_component.name))
256+
expect(page.html).to include(decidim_escape_translated(proposals_component.name).gsub(""", "\""))
257+
expect(page).to have_no_content(translated(meetings_component.name))
257258
end
258259
end
259260
end

decidim-core/app/cells/decidim/card_metadata_cell.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def space_item
2929
return unless show_space?
3030

3131
{
32-
text: decidim_escape_translated(participatory_space.title),
32+
text: translated_attribute(participatory_space.title),
3333
icon: resource_type_icon_key(participatory_space.class),
3434
url: Decidim::ResourceLocatorPresenter.new(participatory_space).path
3535
}

decidim-initiatives/app/helpers/decidim/initiatives/initiatives_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def initiative_nav_items(participatory_space)
1313

1414
components.map do |component|
1515
{
16-
name: decidim_escape_translated(component.name),
16+
name: component.name,
1717
url: main_component_path(component),
1818
active: is_active_link?(main_component_path(component), :inclusive)
1919
}

decidim-initiatives/spec/system/admin/admin_manages_initiative_components_spec.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@
212212

213213
it "hides the component from the menu" do
214214
visit decidim_initiatives.initiative_path(initiative, locale: I18n.locale)
215-
expect(page).to have_content decidim_escape_translated(component.name)
215+
expect(page).to have_content translated(component.name)
216+
expect(page.html).to include decidim_escape_translated(component.name).gsub(""", "\"")
216217

217218
visit decidim_admin_initiatives.components_path(initiative)
218219

@@ -227,7 +228,7 @@
227228
end
228229

229230
visit decidim_initiatives.initiative_path(initiative, locale: I18n.locale)
230-
expect(page).to have_no_content decidim_escape_translated(component.name)
231+
expect(page).to have_no_content translated(component.name)
231232
end
232233
end
233234

decidim-initiatives/spec/system/initiative_spec.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,17 @@
247247

248248
it "shows the components" do
249249
within ".participatory-space__nav-container" do
250-
expect(page).to have_content(decidim_escape_translated(meetings_component.name))
251-
expect(page).to have_no_content(decidim_escape_translated(unpublished_proposals_component.name))
252-
expect(page).to have_content(decidim_escape_translated(blogs_component.name))
250+
expect(page).to have_content(translated(meetings_component.name))
251+
expect(page.html).to include(decidim_escape_translated(meetings_component.name).gsub(""", "\""))
252+
expect(page).to have_no_content(translated(unpublished_proposals_component.name))
253+
expect(page).to have_content(translated(blogs_component.name))
254+
expect(page.html).to include(decidim_escape_translated(blogs_component.name).gsub(""", "\""))
253255
end
254256
end
255257

256258
it "allows visiting the components" do
257259
within ".participatory-space__nav-container" do
258-
click_on decidim_escape_translated(meetings_component.name)
260+
click_on translated(meetings_component.name)
259261
end
260262

261263
expect(page).to have_css('[id^="meetings__meeting"]', count: 3)
@@ -388,15 +390,15 @@
388390

389391
it "has special permissions to create posts" do
390392
within ".participatory-space__nav-container" do
391-
click_on decidim_escape_translated(blogs_component.name)
393+
click_on translated(blogs_component.name)
392394
end
393395

394396
expect(page).to have_content("New post")
395397
end
396398

397399
it "has special permissions to create meetings" do
398400
within ".participatory-space__nav-container" do
399-
click_on decidim_escape_translated(meetings_component.name)
401+
click_on translated(meetings_component.name)
400402
end
401403

402404
expect(page).to have_content("New meeting")

decidim-participatory_processes/app/helpers/decidim/participatory_processes/participatory_process_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def process_nav_items(participatory_space)
7676
] + components.map do |component|
7777
{
7878
id: component.id,
79-
name: decidim_escape_translated(component.name),
79+
name: component.name,
8080
url: main_component_path(component),
8181
active: is_active_link?(main_component_path(component), :inclusive)
8282
}

decidim-participatory_processes/spec/shared/manage_process_components_examples.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@
321321

322322
it "hides the component from the menu" do
323323
visit decidim_participatory_processes.participatory_process_path(participatory_process, locale: I18n.locale)
324-
expect(page).to have_content decidim_escape_translated(component.name)
324+
expect(page).to have_content translated(component.name)
325+
expect(page.html).to include decidim_escape_translated(component.name).gsub(""", "\"")
325326

326327
visit decidim_admin_participatory_processes.components_path(participatory_process)
327328

@@ -336,7 +337,7 @@
336337
end
337338

338339
visit decidim_participatory_processes.participatory_process_path(participatory_process, locale: I18n.locale)
339-
expect(page).to have_no_content decidim_escape_translated(component.name)
340+
expect(page).to have_no_content translated(component.name)
340341
end
341342
end
342343

decidim-participatory_processes/spec/system/participatory_processes_spec.rb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,26 @@
312312

313313
it "shows the components" do
314314
within ".participatory-space__nav-container" do
315-
expect(page).to have_content(decidim_escape_translated(proposals_component.name))
316-
expect(page).to have_no_content(decidim_escape_translated(meetings_component.name))
315+
expect(page).to have_content(translated(proposals_component.name))
316+
expect(page).to have_no_content(translated(meetings_component.name))
317+
expect(page.html).to include decidim_escape_translated(proposals_component.name).gsub(""", "\"")
318+
end
319+
end
320+
321+
it "displays component names with special characters (\", ', &) correctly in the nav links" do
322+
create(
323+
:component,
324+
:published,
325+
participatory_space: participatory_process,
326+
manifest_name: :proposals,
327+
name: { en: "Tracking \"pop\" & 'test'" }
328+
)
329+
visit decidim_participatory_processes.participatory_process_path(participatory_process, locale: I18n.locale)
330+
331+
within ".participatory-space__nav-container" do
332+
expect(page).to have_content('Tracking "pop" & \'test\'')
333+
expect(page).to have_no_content(""")
334+
expect(page).to have_no_content("&")
317335
end
318336
end
319337

0 commit comments

Comments
 (0)