Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle control sequences in formatted errors #1220

Merged
merged 1 commit into from
Jun 6, 2016

Conversation

gomoripeti
Copy link
Contributor

Formatted errors can accidentally contain substrings which are control
sequences for io:format/2. This is a naive attempt to handle such cases.

One example is running xref on the following module
(assuming module m does not exist)

-module(handle_error).

-export([f/0]).

f() -> m:'bobby~stables'().
$ rebar3 xref
===> Verifying dependencies...
===> Compiling myapp
===> Running cross reference analysis...
escript: exception error: bad argument
  in function  io:format/3
     called as io:format(<0.23.0>,
                         "\e[0;31m===> \e[1mWarning: handle_error:f/0 is unused export (Xref)\nWarning: handle_error:f/0 calls undefined function m:bobby~stables/0 (Xref)\n\n\e[0m\e[0m",
                         [])
  in call from rebar3:handle_error/1 (/Users/gomoripeti/git/rebar3/_build/default/lib/rebar/src/rebar3.erl, line 279)

Formatted errors can accidentally contain substrings which are control
sequences for io:format/2. This is a naive attempt to handle such cases.

One example is running xref on the following module
(assuming module m does not exist)

```
-module(handle_error).

-export([f/0]).

f() -> m:'bobby~stables'().
```

```
$ rebar3 xref
===> Verifying dependencies...
===> Compiling myapp
===> Running cross reference analysis...
escript: exception error: bad argument
  in function  io:format/3
     called as io:format(<0.23.0>,
                         "\e[0;31m===> \e[1mWarning: handle_error:f/0 is unused export (Xref)\nWarning: handle_error:f/0 calls undefined function m:bobby~stables/0 (Xref)\n\n\e[0m\e[0m",
                         [])
  in call from rebar3:handle_error/1 (/Users/gomoripeti/git/rebar3/_build/default/lib/rebar/src/rebar3.erl, line 279)
```
@ferd
Copy link
Collaborator

ferd commented Jun 6, 2016

Sounds good to me, good patch!

Thanks!

@ferd ferd merged commit eccbfee into erlang:master Jun 6, 2016
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.

None yet

2 participants