Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

feat(ruby.cson) support quoted heredoc literals #212

Merged
merged 2 commits into from
Oct 17, 2018

Conversation

rmosolgo
Copy link
Contributor

@rmosolgo rmosolgo commented Aug 18, 2017

Thanks for maintaining this project and considering my PR!

Description of the Change

Ruby supports quoted heredocs:

  string1 = <<-STR
    Hello World
  STR

  string2 = <<-"STR"
    Hello World
  STR

  string3 = <<-'STR'
    Hello World
  STR

  shell_block = <<-`COMMAND`
    ls ~
    pwd
  COMMAND

But they aren't captured by the current grammar. This change adds quotes to the heredoc regexps so that they'll be properly tokenized.

Alternate Designs

No alternate deisgns were considered.

Benefits

We use single-quoted heredocs to assert that interpolation is not possible. This is a security check: interpolation can lead to various injection bugs.

Embedded code is not highlighted right now:

image

But after this change, it will be highlighted!

Possible Drawbacks

Added complexity to the heredoc regexp.

Applicable Issues

I didn't find any.

@rmosolgo
Copy link
Contributor Author

@50Wliu Does this concept sound ok to you?

@50Wliu
Copy link
Contributor

50Wliu commented Sep 12, 2017

I'll get around to it soon. Without looking at the code changes, it sounds like a good thing to add support for.

@rmosolgo
Copy link
Contributor Author

Thanks for taking a quick look, glad to hear I'm on the right track :)

@rmosolgo
Copy link
Contributor Author

👋 Hi, if someone has a chance, I'd appreciate a review of this! (or feel free to close it, if it's not a good fit for merging.)

@lee-dohm
Copy link
Contributor

@maxbrunsfeld Can you take a look here perhaps?

@daviwil
Copy link
Contributor

daviwil commented Oct 17, 2018

Hi @rmosolgo, thanks a lot for the PR! The grammar changes look good to me, but do you mind adding an additional case to test backtick quoting? Once that's done this PR should be good to merge!

@daviwil daviwil self-assigned this Oct 17, 2018
@daviwil
Copy link
Contributor

daviwil commented Oct 17, 2018

Just realized I can easily just add the extra case through the web editor :) Once CI passes I'll get this merged and updated!

@daviwil daviwil merged commit f4082a0 into atom:master Oct 17, 2018
@rmosolgo
Copy link
Contributor Author

Woah, thanks! I'm looking forward to using this 😊

@rmosolgo rmosolgo deleted the support-quoted-heredoc branch October 17, 2018 15:51
wingrunr21 added a commit to rubyide/vscode-ruby that referenced this pull request Dec 9, 2018
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.

4 participants