Skip to content
This repository has been archived by the owner. 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

👮

@fofr fofr merged commit a5527b2 into master Apr 7, 2017
1 check passed
1 check passed
continuous-integration/jenkins/branch This commit looks good
Details
@fofr fofr deleted the check-word-arrays branch Apr 7, 2017
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.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.