Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Atom snippets fail to treat an octal in multiline strings as expected #16184

Closed
philoserf opened this issue Nov 14, 2017 · 3 comments
Closed
Labels
wrong-repo Issues that are filed to the wrong Atom repository.

Comments

@philoserf
Copy link

Description

Atom snippets fail to treat an octal in multiline strings as expected. While the specification at https://github.com/bevry/cson proclaims "Multi-line Strings! Without Quote Escaping!" and gives no warning about octal Atom editor gives an error message while saving a snippet definition containing an octal.

Escaping a closing brace in a multi-line string is in the README for the snippets package: https://github.com/atom/snippets/blob/edf7db4e5f3d9bb0354745433cf09e14c933d75a/README.md#multi-line-snippet-body

Using the same technique to escape the opening backslash of the octal delivers the same error message as with no escaping.

Steps to Reproduce

  1. Open $HOME/.atom/snippets.cson
  2. Save the CSON snippet definition described in Actual behavior below
  3. Save the file

Expected behavior:

Unlike a closing brace, other values do not require escaping in snippets.cson using CSON multi-line strings.

OR, a means of escaping the octal exists for snippets as that require them.

OR, the README is updated to reflect this limitation in addition to the closing brace limit.

Actual behavior:

While running Atom like this, atom --safe

Add this code fragment snippet definition to $HOME/.atom/snippets.cson:

'.source.makefile':
  'makefile':
    prefix: 'start.make'
    description: 'Makefile help'
    body: '''
      .DEFAULT_GOAL := help
      .PHONY: help
      help:
      	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
      '''

Upon saving the file, get this error:

Failed to load snippets from '/.../.atom/snippets.cson'

/.../.atom/snippets.cson: ocatal esccape sequences are not allowed \03

Using the debugger arrive at this error message:

fs.js line 122
Error reading snippets file '/Users/mark/.atom/snippets.cson': [stdin]:147:99: error: octal escape sequences are not allowed \03
      	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

Which comes from this line/function:

function nullCheck(path, callback) {
  if (('' + path).indexOf('\u0000') !== -1) {
    var er = new Error('Path must be a string without null bytes');
    er.code = 'ENOENT';
    if (typeof callback !== 'function')
      throw er;
    process.nextTick(callback, er); // <-- line 122
    return false;
  }
  return true;
}

Reproduces how often: Always

Versions

> atom --version
Atom    : 1.22.0
Electron: 1.6.15
Chrome  : 56.0.2924.87
Node    : 7.4.0

> apm --version
apm  1.18.8
npm  3.10.10
node 6.9.5 x64
python 2.7.10
git 2.15.0

> sw_vers
ProductName:	Mac OS X
ProductVersion:	10.13.1
BuildVersion:	17B48

Additional Information

Not certain to which of these this issue belongs:

@rsese
Copy link
Contributor

rsese commented Nov 15, 2017

Thanks for the report! Hmmm, I think https://github.com/atom/snippets would be a good place for this - I can re-open it there later tonight if you don't get to it first. And if we need to move it again I can take care of that.

@rsese rsese closed this as completed Nov 15, 2017
@rsese rsese added the wrong-repo Issues that are filed to the wrong Atom repository. label Nov 15, 2017
@philoserf
Copy link
Author

Moved to atom/snippets#256

@lock
Copy link

lock bot commented May 15, 2018

This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!

@lock lock bot locked as resolved and limited conversation to collaborators May 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
wrong-repo Issues that are filed to the wrong Atom repository.
Projects
None yet
Development

No branches or pull requests

3 participants
@rsese @philoserf and others