1. 27 2月, 2018 1 次提交
    • Z
      Uses the absolute path for system test screenshots · fc778164
      Zamith 提交于
      Why:
      
      * When getting an error that generates a screenshot it would be helpful
        to be able to ctrl+click it to quickly open it in the browser, which
        does not work with relative paths
      
      This change addresses the need by:
      
      * Changing `image_path` to disregard the relative path and use the
        absolute one instead
      fc778164
  2. 25 2月, 2018 1 次提交
  3. 22 2月, 2018 1 次提交
  4. 19 2月, 2018 4 次提交
    • A
      Add support for automatic nonce generation for Rails UJS · 31abee03
      Andrew White 提交于
      Because the UJS library creates a script tag to process responses it
      normally requires the script-src attribute of the content security
      policy to include 'unsafe-inline'.
      
      To work around this we generate a per-request nonce value that is
      embedded in a meta tag in a similar fashion to how CSRF protection
      embeds its token in a meta tag. The UJS library can then read the
      nonce value and set it on the dynamically generated script tag to
      enable it to execute without needing 'unsafe-inline' enabled.
      
      Nonce generation isn't 100% safe - if your script tag is including
      user generated content in someway then it may be possible to exploit
      an XSS vulnerability which can take advantage of the nonce. It is
      however an improvement on a blanket permission for inline scripts.
      
      It is also possible to use the nonce within your own script tags by
      using `nonce: true` to set the nonce value on the tag, e.g
      
          <%= javascript_tag nonce: true do %>
            alert('Hello, World!');
          <% end %>
      
      Fixes #31689.
      31abee03
    • U
      Avoid method_redefined warnings in RouteSet::NamedRouteCollection · 899e2dad
      utilum 提交于
      Before:
      ```
      ~/.rbenv/versions/2.5.0/bin/ruby -w -Itest -Ilib -I../activesupport/lib -I../actionpack/lib -I../actionview/lib -I../activemodel/lib test/application/routing_test.rb
      Run options: --seed 5851
      
      .......~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:156: warning: method redefined; discarding old custom_path
      ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_path was here
      ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:162: warning: method redefined; discarding old custom_url
      ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_url was here
      ....~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:156: warning: method redefined; discarding old custom_path
      ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_path was here
      ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:162: warning: method redefined; discarding old custom_url
      ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_url was here
      ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:156: warning: method redefined; discarding old custom_path
      ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_path was here
      ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:162: warning: method redefined; discarding old custom_url
      ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_url was here
      ..........~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:156: warning: method redefined; discarding old custom_path
      ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_path was here
      ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:162: warning: method redefined; discarding old custom_url
      ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_url was here
      ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:156: warning: method redefined; discarding old custom_path
      ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_path was here
      ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:162: warning: method redefined; discarding old custom_url
      ~/code/rails/actionpack/lib/action_dispatch/routing/route_set.rb:321: warning: previous definition of custom_url was here
      .....
      
      Finished in 13.233638s, 1.9647 runs/s, 5.8185 assertions/s.
      26 runs, 77 assertions, 0 failures, 0 errors, 0 skips
      ```
      
      After:
      ```
      ~/.rbenv/versions/2.5.0/bin/ruby -w -Itest -Ilib -I../activesupport/lib -I../actionpack/lib -I../actionview/lib -I../activemodel/lib test/application/routing_test.rb
      Run options: --seed 38072
      
      ..........................
      
      Finished in 12.009632s, 2.1649 runs/s, 6.4115 assertions/s.
      26 runs, 77 assertions, 0 failures, 0 errors, 0 skips
      ```
      899e2dad
    • A
      Remove trailing semi-colon from CSP · d85283cc
      Andrew White 提交于
      Although the spec[1] is defined in such a way that a trailing semi-colon
      is valid it also doesn't allow a semi-colon by itself to indicate an
      empty policy. Therefore it's easier (and valid) just to omit it rather
      than to detect whether the policy is empty or not.
      
      [1]: https://www.w3.org/TR/CSP2/#policy-syntax
      d85283cc
    • A
      Revert "Merge pull request #32045 from eagletmt/skip-csp-header" · 52a1f1c2
      Andrew White 提交于
      This reverts commit 86f7c269, reversing
      changes made to 5ece2e4a.
      
      If a policy is set then we should generate it even if it's empty.
      However what is happening is that we're accidentally generating an
      empty policy when the initializer is commented out by default.
      52a1f1c2
  5. 18 2月, 2018 5 次提交
  6. 17 2月, 2018 4 次提交
  7. 16 2月, 2018 4 次提交
  8. 15 2月, 2018 1 次提交
    • S
      PERF: dedupe scanned route fragments · 24131d4a
      Sam 提交于
      Per: https://bugs.ruby-lang.org/issues/13077 String @- will dedupe strings. 
      
      This takes advantage of this by deduping route fragments that are full of duplication usually. 
      
      For Discourse:
      
      Before:
      
      Total allocated: 207574305 bytes (2214916 objects)
      Total retained:  36470010 bytes (322194 objects)
      
      After 
      
      Total allocated: 207556847 bytes (2214711 objects)
      Total retained:  36327973 bytes (318627 objects) <- object that GC can not collect
      
      
      So we save 3500 or so RVALUES this way, not the largest saving in the world, but worth it especially for large route files.
      24131d4a
  9. 11 2月, 2018 1 次提交
  10. 10 2月, 2018 1 次提交
  11. 01 2月, 2018 2 次提交
  12. 31 1月, 2018 1 次提交
  13. 30 1月, 2018 2 次提交
  14. 26 1月, 2018 4 次提交
  15. 22 1月, 2018 1 次提交
  16. 20 1月, 2018 1 次提交
  17. 18 1月, 2018 1 次提交
    • K
      Enable autocorrect for `Lint/EndAlignment` cop · 5ac6ec54
      Koichi ITO 提交于
      ### Summary
      
      This PR changes .rubocop.yml.
      
      Regarding the code using `if ... else ... end`, I think the coding style
      that Rails expects is as follows.
      
      ```ruby
      var = if cond
        a
      else
        b
      end
      ```
      
      However, the current .rubocop.yml setting does not offense for the
      following code.
      
      ```ruby
      var = if cond
              a
            else
              b
            end
      ```
      
      I think that the above code expects offense to be warned.
      Moreover, the layout by autocorrect is unnatural.
      
      ```ruby
      var = if cond
        a
            else
              b
            end
      ```
      
      This PR adds a setting to .rubocop.yml to make an offense warning and
      autocorrect as expected by the coding style.
      And this change also fixes `case ... when ... end` together.
      
      Also this PR itself is an example that arranges the layout using
      `rubocop -a`.
      
      ### Other Information
      
      Autocorrect of `Lint/EndAlignment` cop is `false` by default.
      https://github.com/bbatsov/rubocop/blob/v0.51.0/config/default.yml#L1443
      
      This PR changes this value to `true`.
      
      Also this PR has changed it together as it is necessary to enable
      `Layout/ElseAlignment` cop to make this behavior.
      5ac6ec54
  18. 17 1月, 2018 1 次提交
  19. 16 1月, 2018 1 次提交
  20. 12 1月, 2018 1 次提交
  21. 09 1月, 2018 1 次提交
  22. 08 1月, 2018 1 次提交