diff --git a/Gemfile b/Gemfile index 6688a334381..5cc75dda44b 100644 --- a/Gemfile +++ b/Gemfile @@ -79,6 +79,7 @@ gem "observer", "~> 0.1.2" # launchdarkly-server-sdk-8.0.0 gem "sprockets-rails", "~> 3.5" gem "importmap-rails", "~> 2.0" gem "stimulus-rails", "~> 1.3" # this adds stimulus-loading.js so it must be available at runtime +gem "better_html", "~> 2.1" group :assets, :development do gem "tailwindcss-rails", "~> 2.6" diff --git a/Gemfile.lock b/Gemfile.lock index e290881ed40..18526310b42 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -131,6 +131,13 @@ GEM base64 (0.2.0) bcrypt (3.1.20) benchmark-ips (2.12.0) + better_html (2.1.1) + actionview (>= 6.0) + activesupport (>= 6.0) + ast (~> 2.0) + erubi (~> 1.4) + parser (>= 2.4) + smart_properties bigdecimal (3.1.8) bindata (2.5.0) bitarray (1.2.0) @@ -673,6 +680,7 @@ GEM simplecov (~> 0.19) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) + smart_properties (1.17.0) snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) @@ -775,6 +783,7 @@ DEPENDENCIES aws-sdk-s3 (~> 1.156) aws-sdk-sqs (~> 1.80) bcrypt (~> 3.1) + better_html (~> 2.1) bootsnap (~> 1.18) brakeman (~> 6.1) browser (~> 6.0) @@ -913,6 +922,7 @@ CHECKSUMS base64 (0.2.0) sha256=0f25e9b21a02a0cc0cea8ef92b2041035d39350946e8789c562b2d1a3da01507 bcrypt (3.1.20) sha256=8410f8c7b3ed54a3c00cd2456bf13917d695117f033218e2483b2e40b0784099 benchmark-ips (2.12.0) sha256=09dd4d5be05db42470e7e7b01be7310564073a054e35d9d9ec7840c523f3dbcb + better_html (2.1.1) sha256=046c3551d1488a3f2939a7cac6fabf2bde08c32e135c91fcd683380118e5af55 bigdecimal (3.1.8) sha256=a89467ed5a44f8ae01824af49cbc575871fa078332e8f77ea425725c1ffe27be bindata (2.5.0) sha256=29dccb8ba1cc9de148f24bb88930840c62db56715f0f80eccadd624d9f3d2623 bitarray (1.2.0) sha256=7f9f31fadbd87bf51544cf13058e81cd6ec408ff40f127902cef3d6767b23f11 @@ -1130,6 +1140,7 @@ CHECKSUMS simplecov-cobertura (2.1.0) sha256=2c6532e34df2e38a379d72cef9a05c3b16c64ce90566beebc6887801c4ad3f02 simplecov-html (0.12.3) sha256=4b1aad33259ffba8b29c6876c12db70e5750cb9df829486e4c6e5da4fa0aa07b simplecov_json_formatter (0.1.4) sha256=529418fbe8de1713ac2b2d612aa3daa56d316975d307244399fa4838c601b428 + smart_properties (1.17.0) sha256=f9323f8122e932341756ddec8e0ac9ec6e238408a7661508be99439ca6d6384b snaky_hash (2.0.1) sha256=1ac87ec157fcfe7a460e821e0cd48ae1e6f5e3e082ab520f03f31a9259dbdc31 sprockets (4.2.1) sha256=951b13dd2f2fcae840a7184722689a803e0ff9d2702d902bd844b196da773f97 sprockets-rails (3.5.1) sha256=c44626cb3887a1a8b572ca258685db33b4ebd041aa73428a716eac444ee5ef48 diff --git a/app/controllers/totps_controller.rb b/app/controllers/totps_controller.rb index dde3e0ff8fc..1abb78414ec 100644 --- a/app/controllers/totps_controller.rb +++ b/app/controllers/totps_controller.rb @@ -15,7 +15,7 @@ def new session[:totp_seed] = @seed session[:totp_seed_expire] = Gemcutter::MFA_KEY_EXPIRY.from_now.utc.to_i text = ROTP::TOTP.new(@seed, issuer: issuer).provisioning_uri(current_user.email) - @qrcode_svg = RQRCode::QRCode.new(text, level: :l).as_svg(module_size: 6) + @qrcode_svg = RQRCode::QRCode.new(text, level: :l).as_svg(module_size: 6).html_safe # rubocop:disable Rails/OutputSafety end def create diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index bd3c1f8af10..62447d8a786 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,4 +1,6 @@ module ApplicationHelper + include BetterHtml::Helpers + def page_title combo = "#{t :title} | #{t :subtitle}" # If instance variable @title_for_header_only is present then it is added to combo title string diff --git a/app/javascript/src/transitive_dependencies.js b/app/javascript/src/transitive_dependencies.js index d9faadbb6bb..619ca040b71 100755 --- a/app/javascript/src/transitive_dependencies.js +++ b/app/javascript/src/transitive_dependencies.js @@ -1,12 +1,14 @@ import $ from "jquery"; $(document).on('click', '.deps_expanded-link', function () { + try { var current = $(this); - var gem_id = $(this).attr('data-gem_id'); - var version_id = $(this).attr('data-version'); + var gem_id = this.dataset.gemId; + var version_id = this.dataset.version; + const url = "/gems/"+gem_id+"/versions/"+version_id+"/dependencies.json"; $.ajax({ type: "get", - url: "/gems/"+gem_id+"/versions/"+version_id+"/dependencies.json", + url: url, success: function(resp) { renderDependencies(resp, current); }, @@ -15,6 +17,9 @@ $(document).on('click', '.deps_expanded-link', function () { current.parent().next().next().html(error_message); } }); +} catch (e) { + alert(e); +} }); function renderDependencies(resp, current) { diff --git a/app/views/dependencies/_dependencies.html.erb b/app/views/dependencies/_dependencies.html.erb index 7e4a8c71cfa..c7a311d6f61 100644 --- a/app/views/dependencies/_dependencies.html.erb +++ b/app/views/dependencies/_dependencies.html.erb @@ -5,7 +5,7 @@