Skip to content
This repository has been archived by the owner on Jan 6, 2020. It is now read-only.

Protect against commas and quotes in word arrays #71

Merged
merged 1 commit into from Apr 7, 2017
Merged

Conversation

fofr
Copy link
Contributor

@fofr fofr commented Apr 7, 2017

A comma in a word array caused a subtle bug in Publisher:
alphagov/publisher#615

We encourage use of %w, we should protect against the risk of misuse.

Example offense that would have prevented bug:

Offenses:

app/services/publishing_api_workflow_bypass_publisher.rb:52:33: W: Lint/PercentStringArray: Within %w/%W, quotes and ',' are unnecessary and may be unwanted in the resulting strings. 
      .where(state: { "$nin" => %w(published, archived) })
                                ^^^^^^^^^^^^^^^^^^^^^^^

cc @whoojemaflip

A comma in a word array caused a subtle bug in Publisher:
alphagov/publisher#615

We encourage use of %w, we should protect against the risk of misuse.
Copy link

@whoojemaflip whoojemaflip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👮

@fofr fofr merged commit a5527b2 into master Apr 7, 2017
@fofr fofr deleted the check-word-arrays branch April 7, 2017 15:37
fofr added a commit that referenced this pull request Apr 7, 2017
* Enable `Lint/PercentStringArray`, protect against commas and quotes
in word arrays (#71)
* Disable `Style/SafeNavigation` (#68)
@fofr fofr mentioned this pull request Apr 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants