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

Escape quotes in strings sent from SCIDE to lang #3277

Merged
merged 3 commits into from Jan 21, 2018

Conversation

Projects
None yet
3 participants
@brianlheim
Member

brianlheim commented Nov 4, 2017

Fixes #1036, tested and works (on macOS 10.13 high sierra).

Reproducer

  1. Start scide.
  2. Type the line "broken
  3. Select-all, and Cmd-D (to search documentation) or Cmd-U (to look up references).

Old behavior

Errors:

ERROR: syntax error, unexpected NAME, expecting ')'
  in interpreted text
  line 1 char 32:

  HelpBrowser.openHelpFor(""broken") 
                            ^^^^^^
-----------------------------------
ERROR: Command line parse failed
ERROR: syntax error, unexpected NAME, expecting ')'
  in interpreted text
  line 1 char 88:

  ScIDE.request("{ec39ccb4-c981-43ac-a72e-a75439af6b6c}",'findReferencesToSymbol',""broken") 
                                                                                    ^^^^^^
-----------------------------------
ERROR: Command line parse failed

Also freezes the help browser.

New behavior

Works without error/complaint.

Addendum

I noticed similar opportunities for this issue to arise in other IDEs (search result at the end of this post), but I think this is more pressing/issue-worthy because (a) the IDE has widest usage and (b) this issue actually causes a major freeze. I am not sure if it does in other contexts. Since I'm not a user of any other SC environments, I haven't changed any of those files.

[brianheim@BrianMBP supercollider]$ rg openHelpFor
HelpSource/Classes/HelpBrowser.schelp
28:method:: openHelpFor
40:method:: openHelpForMethod

SCClassLibrary/DefaultLibrary/Main.sc
119:		HelpBrowser.openHelpFor(this.getCurrentSelection);

editors/scel/el/sclang-help.el
628:      (sclang-eval-string (sclang-format "HelpBrowser.openHelpFor(%o)" topic))

editors/sced/sced/WindowHelper.py
289:        self.__lang.evaluate("HelpBrowser.openHelpFor(\"" + text + "\");")

editors/sced/sced3/supercollider.py
527:        cmd = 'HelpBrowser.openHelpFor(\"' + text + '\");'

editors/sc-ide/widgets/help_browser.cpp
187:    QString code = QStringLiteral("HelpBrowser.openHelpFor(\"%1\")").arg(escaped);
193:    QString code = QStringLiteral("HelpBrowser.openHelpForMethod( %1.findMethod(\\%2) )").arg(className, methodName);

editors/scvim/ftplugin/supercollider.vim
244:  call SendToSCSilent('HelpBrowser.openHelpFor("' . a:subject . '");')

SCClassLibrary/Common/Core/Kernel.sc
517:		HelpBrowser.openHelpForMethod(this);

SCClassLibrary/Common/Quarks/Quark.sc
277:			^HelpBrowser.openHelpFor(p);

editors/sced/scedwin/py/WindowHelper.py
307:        self.__lang.evaluate("HelpBrowser.openHelpFor(\"" + text + "\");")

SCClassLibrary/Common/GUI/tools/HelpBrowser.sc
59:	*openHelpFor {|text|
66:	*openHelpForMethod {|method|

SCClassLibrary/Common/GUI/PlusGUI/Collections/StringPlusGUI.sc
94:			HelpBrowser.openHelpFor(this);
[brianheim@BrianMBP supercollider]$ rg gotoHelpFor
editors/sc-ide/core/main.cpp
292:    helpDock->browser()->gotoHelpFor(symbol);
300:    helpDock->browser()->gotoHelpForMethod(className, methodName);

editors/sc-ide/widgets/help_browser.cpp
183:void HelpBrowser::gotoHelpFor( const QString & symbol )
192:void HelpBrowser::gotoHelpForMethod( const QString & className, const QString & methodName )

editors/sc-ide/widgets/main_window.cpp
1612:    mHelpBrowserDocklet->browser()->gotoHelpFor("Guides/SCIde");

editors/sc-ide/widgets/help_browser.hpp
99:    void gotoHelpFor( const QString & );
100:    void gotoHelpForMethod( const QString & className, const QString & methodName );

editors/sc-ide/widgets/code_editor/autocompleter.cpp
1312:    helpDock->browser()->gotoHelpFor(symbol);

@brianlheim brianlheim added this to the 3.9.1 milestone Nov 4, 2017

@brianlheim

This comment has been minimized.

Member

brianlheim commented Nov 4, 2017

I milestoned this 3.9.1, would rather not shove it into 3.9.0.

QString escapedClass{className};
QString escapedMethod{methodName};
escapedClass.replace('\"', "\\\"");
escapedMethod.replace('\"', "\\\"");

This comment has been minimized.

@snappizz

snappizz Jan 14, 2018

Member

small amount of duplicated code here -- how about making an escapeDoubleQuote function?

This comment has been minimized.

@brianlheim

brianlheim Jan 16, 2018

Member

good point, I've done that now. :)

scide: factor out a common bit of escaping code
escapeDoubleQuotes in help_browser.cpp

@patrickdupuis patrickdupuis merged commit b27128d into supercollider:3.9 Jan 21, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@brianlheim brianlheim deleted the brianlheim:issue/1036 branch Jan 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment