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

Invalid "\" crashes lintr #559

Closed
renkun-ken opened this issue Nov 5, 2020 · 0 comments · Fixed by #560
Closed

Invalid "\" crashes lintr #559

renkun-ken opened this issue Nov 5, 2020 · 0 comments · Fixed by #560

Comments

@renkun-ken
Copy link
Collaborator

renkun-ken commented Nov 5, 2020

If the source code contains any invalid use of \, then lintr::lint() will stop working:

col <- c("a", \)

The case could be simplified to the following:

> parse(text = "\\")                                                                                                        
Error in parse(text = "\\") : <text>:1:1: unexpected input
1: \
    ^
Backtrace:
1: parse(text = "\\")

> lintr::lint("\\\n")                                                                                                       
Error in read_xml.raw(charToRaw(enc2utf8(x)), "UTF-8", ..., as_html = as_html,  : 
  StartTag: invalid element name [68]
Backtrace:
1: read_xml.raw(charToRaw(enc2utf8(x)), "UTF-8", ..., as_html = as_html, 
2: read_xml.character(xmlparsedata::xml_parse_data(pc))
3: xml2::read_xml(xmlparsedata::xml_parse_data(pc))
4: FUN(X[[i]], ...)
5: lapply(X = top_level_expressions(parsed_content), FUN = get_single_source_expression, 
6: get_source_expressions(filename)
7: lintr::lint("\\\n")

Looks like it is caused by xmlparsedata writing invalid XML and lintr does not handle such case.

Before error occurs, pc got the following value:

  line1 col1 line2 col2 id parent token terminal text
1     1    1     1    1  1      0    \\    FALSE   \\

xmlparsedata::xml_parse_data(pc) produces the following XML with invalid tokens:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<exprlist>
  <\ line1="1" col1="1" line2="1" col2="1" start="3" end="3">\
  </\>
</exprlist>
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 a pull request may close this issue.

1 participant