Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Conversation

@xiemaisi
Copy link
Contributor

@xiemaisi xiemaisi commented Jun 26, 2017

This fixes a few minor issues found by lgtm; for more details see https://lgtm.com/projects/g/adobe/brackets/alerts/.

The fixes in the first three commits are fairly obvious, the last two commits involve some educated guessing as to the intended semantics of the code involved.

The previous regexp looked a little dubious, since `[\\\\]` means exactly the same as `[\\]`. Note, however, that `/x*y/.test(s)` returns true iff `/y/.test(s)` does, so the character class was redundant to begin with.
Copy link
Collaborator

@petetnt petetnt left a comment

Choose a reason for hiding this comment

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

Cool stuff @xiemaisi, LGTM but that last one is bit tricky so someone else should check it too.

var r = extensionManager.downloadFile(downloadId, urlInfo.url, PreferencesManager.get("proxy"));
r.done(function (result) {
d.resolve({ localPath: FileUtils.convertWindowsPathToUnixPath(result), filenameHint: urlInfo.filenameHint });
d.resolve({ localPath: FileUtils.convertWindowsPathToUnixPath(result), filenameHint: filename });
Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes sense but I am not 100% sure either, @swmitra?

@xiemaisi
Copy link
Contributor Author

I've removed the last two commits with the less obvious fixes; I'll put them up as a separate PR.

@xiemaisi
Copy link
Contributor Author

@petetnt, does this look safer now?

Copy link
Collaborator

@petetnt petetnt left a comment

Choose a reason for hiding this comment

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

LGTM with a comment, someone else should do a double check too. @saurabh95 could you do that 🙏

t.origin = "ecmascript";
if (kind === "string") {
if (/[\\\\]*[^\\]"/.test(t.value)) {
if (/[^\\]"/.test(t.value)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks bit scary to me, but didn't manage to find any differences after running some tests cases by hand 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

This one looks scary to me as well. Will do some testing around it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not as scary as you might think: the original code looks for a substring of t.value that contains zero or more backslashes, followed by something that isn't a backslash, followed by a double quote. This is the same as simply looking for a substring consisting of something that isn't a backslash followed by a double quote, which is what the new code does.

(Note that lgtm actually only highlighted the fact that [\\\\] is redundant and means the same as [\\] or indeed \\.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh ok. seems good to me. We can merge this after 1.10 release

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good stuff @xiemaisi, merging this in and will land in 1.11. Hopefully we get the other fixes found by lgtm in too.

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