OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Escape single quotes from i18n string in sql query
Christophe Bliardf0f17d9293bf
diff --git a/lib/api/v3/projects/project_sql_representer.rb b/lib/api/v3/projects/project_sql_representer.rbindex 3f261eafa18..f5552bde2b1 100644--- a/lib/api/v3/projects/project_sql_representer.rb+++ b/lib/api/v3/projects/project_sql_representer.rb@@ -77,7 +77,8 @@ module API<<-SQL.squishCASEWHEN ancestors.id IS NOT NULL- THEN json_build_object('href', format('/api/v3/projects/%s', ancestors.id), 'title', ancestors.name)+ THEN json_build_object('href', format('/api/v3/projects/%s', ancestors.id),+ 'title', ancestors.name)ELSE NULLENDSQL@@ -85,9 +86,11 @@ module API<<-SQL.squishCASEWHEN ancestors.id IS NOT NULL AND ancestors.id IN (SELECT id FROM visible_projects)- THEN json_build_object('href', format('/api/v3/projects/%s', ancestors.id), 'title', ancestors.name)+ THEN json_build_object('href', format('/api/v3/projects/%s', ancestors.id),+ 'title', ancestors.name)WHEN ancestors.id IS NOT NULL AND ancestors.id NOT IN (SELECT id FROM visible_projects)- THEN json_build_object('href', '#{API::V3::URN_UNDISCLOSED}', 'title', '#{I18n.t(:'api_v3.undisclosed.ancestor')}')+ THEN json_build_object('href', '#{API::V3::URN_UNDISCLOSED}',+ 'title', #{ActiveRecord::Base.connection.quote(I18n.t(:'api_v3.undisclosed.ancestor'))})ELSE NULLENDSQLdiff --git a/spec/lib/api/v3/projects/project_sql_representer_rendering_spec.rb b/spec/lib/api/v3/projects/project_sql_representer_rendering_spec.rbindex 404baa7870b..28cc90ee8ad 100644--- a/spec/lib/api/v3/projects/project_sql_representer_rendering_spec.rb+++ b/spec/lib/api/v3/projects/project_sql_representer_rendering_spec.rb@@ -154,6 +154,32 @@ describe ::API::V3::Projects::ProjectSqlRepresenter, 'rendering' do}.to_json)end++ context 'when in a foreign language with single quotes in the translation hint text' do+ before do+ I18n.locale = :fr+ end++ it 'renders as expected' do+ expect(json)+ .to be_json_eql(+ {+ _links: {+ ancestors: [+ {+ href: api_v3_paths.project(grandparent.id),+ title: grandparent.name+ },+ {+ href: API::V3::URN_UNDISCLOSED,+ title: I18n.t(:'api_v3.undisclosed.ancestor')+ }+ ]+ }+ }.to_json+ )+ end+ endendcontext 'with an archived ancestor but with the user being admin' do