Skip to content

Restrict special chars from prefixing new gem names#2432

Merged
2 commits merged intomasterfrom
restrict_special_chars_from_prefixing_new_gem_names
Oct 10, 2018
Merged

Restrict special chars from prefixing new gem names#2432
2 commits merged intomasterfrom
restrict_special_chars_from_prefixing_new_gem_names

Conversation

@bronzdoc
Copy link
Copy Markdown
Contributor

Description:

closes #2430

A user should not be able to create a gem with a ., - or _ as a prefix in a gem name


Tasks:

  • Describe the problem / feature
  • Write tests
  • Write code to solve the problem
  • Get code review from coworkers / friends

I will abide by the code of conduct.

Copy link
Copy Markdown
Member

@colby-swandale colby-swandale left a comment

Choose a reason for hiding this comment

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

Nice and simple!

@bronzdoc
Copy link
Copy Markdown
Contributor Author

Thanks for the review @colby-swandale!

@bronzdoc
Copy link
Copy Markdown
Contributor Author

@bundlerbot r+

ghost pushed a commit that referenced this pull request Oct 10, 2018
2432: Restrict special chars from prefixing new gem names r=bronzdoc a=bronzdoc

# Description:
closes #2430

A user should not be able to create a gem with a `.`, `-` or `_` as a prefix in a gem name
______________

# Tasks:

- [ ] Describe the problem / feature
- [ ] Write tests
- [ ] Write code to solve the problem
- [ ] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).


Co-authored-by: Luis Sagastume <lsagastume1990@gmail.com>
@ghost
Copy link
Copy Markdown

ghost commented Oct 10, 2018

Build succeeded

@ghost ghost merged commit 0283a62 into master Oct 10, 2018
@hsbt hsbt deleted the restrict_special_chars_from_prefixing_new_gem_names branch October 15, 2018 06:26
@asottile
Copy link
Copy Markdown

I know it's silly, but I was depending on this behaviour for https://pre-commit.com to pick a gem name that would never conflict. I've gone through and fixed all of my uses but unfortunately I've caused to be a pattern.

This wasn't called out at all in the 3.0 changelog despite being a breaking change, it might be good to call that out.

For others seeing the error message, the message is (in my case):

 invalid value for attribute name: "__fake_gem" can not begin with a period, dash, or underscore

jumanjiman added a commit to jumanjihouse/pre-commit-hooks that referenced this pull request Jan 15, 2019
Change name of `__fake_gem` to `fake_gem__` for rubygems 3.x compatibility

The name `__fake_gem` is incompatible with `rubygems >= 3`. This changes the name to `fake_gem__`. I'm open to other ideas for naming but figured this had just as little chance of a name collision as the previous name which seemed like the original intent.

Symptom:

```
An unexpected error has occurred: CalledProcessError: Command: ('/usr/local/bin/ruby', u'/usr/local/bin/gem', 'build', '__fake_gem.gemspec')

Errors: 
    WARNING:  See http://guides.rubygems.org/specification-reference/ for help
    ERROR:  While executing gem ... (Gem::InvalidSpecificationException)
        invalid value for attribute name: "__fake_gem" can not begin with a period, dash, or underscore
```

Reference:
ruby/rubygems#2432 (comment)
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

You can make hidden gems. It kinda breaks things and it's maybe a security vulnerability. Hiiiiii, everybody! 👋

3 participants