From f75de2b48fa37879ad02848ab0d2c571eb06da65 Mon Sep 17 00:00:00 2001 From: Alexander Graul Date: Tue, 5 Nov 2019 11:39:36 +0100 Subject: [PATCH 1/2] Use Ruby 1.9 hash syntax for /package routes This change is update the syntax to bring it in line with rubocop's default. Rubocop does not check config/routes.rb, but that should not stop us from sticking to it. --- config/routes.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 3a68cf987..d861fefa6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,15 +21,15 @@ get 'images.xml', to: 'images#images' controller :package do - get 'package/:package' => :show, :constraints => { :package => /[-+\w\.:\@]+/ } - get 'package/thumbnail/:package.png' => :thumbnail, :constraints => { :package => /[-+\w\.:\@]+/ } - get 'package/screenshot/:package.png' => :screenshot, :constraints => { :package => /[-+\w\.:\@]+/ } + get 'package/:package', action: :show, constraints: { package: /[-+\w\.:\@]+/ } + get 'package/thumbnail/:package.png', action: :thumbnail, constraints: { package: /[-+\w\.:\@]+/ } + get 'package/screenshot/:package.png', action: :screenshot, constraints: { package: /[-+\w\.:\@]+/ } - get 'explore' => :explore - get 'packages' => :explore - get 'appstore' => :explore - get 'packages/:category' => :category, :constraints => { :category => /[\w\-\.: ]+/ } - get 'appstore/:category' => :category, :constraints => { :category => /[\w\-\.: ]+/ } + get 'explore', action: :explore + get 'packages', action: :explore + get 'appstore', action: :explore + get 'packages/:category', action: :category, constraints: { category: /[\w\-\.: ]+/ } + get 'appstore/:category', action: :category, constraints: { category: /[\w\-\.: ]+/ } end namespace 'download' do From eca6ab2133e8f1528df3981ff95f7f7154247968 Mon Sep 17 00:00:00 2001 From: Alexander Graul Date: Tue, 5 Nov 2019 11:49:29 +0100 Subject: [PATCH 2/2] Accept "~" as part of a package name Some packages contain a "~", for example: keepassxc-dbgsym_2.5.0-1ppa1~bionic1_amd64.ddeb If this example should be returned from OBS in the first place is something I am not sure about, but we should handle arbitrary package names and I don't see a reason why "~" should not be accepted as part of a name. Fixes https://github.com/openSUSE/software-o-o/issues/697 --- app/controllers/application_controller.rb | 2 +- config/routes.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e1bab00a8..d3487b164 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -130,7 +130,7 @@ def required_parameters(*parameters) end def valid_package_name?(name) - name =~ /^[[:alnum:]][-+\w\.:\@]*$/ + name =~ /^[[:alnum:]][-+~\w\.:\@]*$/ end def valid_pattern_name?(name) diff --git a/config/routes.rb b/config/routes.rb index d861fefa6..f1bcb47b5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,9 +21,9 @@ get 'images.xml', to: 'images#images' controller :package do - get 'package/:package', action: :show, constraints: { package: /[-+\w\.:\@]+/ } - get 'package/thumbnail/:package.png', action: :thumbnail, constraints: { package: /[-+\w\.:\@]+/ } - get 'package/screenshot/:package.png', action: :screenshot, constraints: { package: /[-+\w\.:\@]+/ } + get 'package/:package', action: :show, constraints: { package: /[-+~\w\.:\@]+/ } + get 'package/thumbnail/:package.png', action: :thumbnail, constraints: { package: /[-+~\w\.:\@]+/ } + get 'package/screenshot/:package.png', action: :screenshot, constraints: { package: /[-+~\w\.:\@]+/ } get 'explore', action: :explore get 'packages', action: :explore