SUMMARY The searched text in external tool "Google Selected Text" is not escaped. If it contains meaningful, correct URL characters (like &, ?), they can be interpreted by browser as URL parts, not search query. STEPS TO REPRODUCE 1. Highlight text with some special characters, e.g. 'something to search & something' 2. Use "Google Selected Text" tool 3. See browser address bar and google search field OBSERVED RESULT Address bar contains full searched text (in the same form in case of Firefox) but google search field contains only the part before '&', e.g. 'something to search'. EXPECTED RESULT Google search field contains whole text. SOFTWARE/OS VERSIONS Windows: 10, 19H1 Linux/KDE Plasma: Arch Linux (available in About System) KDE Plasma Version: 5.17.5 KDE Frameworks Version: 5.66.0 Qt Version: 5.14.0 ADDITIONAL INFORMATION Thanks for the great editor :)
The problem here is that %{Document:Selection:Text} is simply the raw text, not escaped. A solution to this could be to add another variable called: %{EscapeText:<value>}, we then could write: https://www.google.com/search?q=%{EscapeText:%{Document:Selection:Text}} Would 'EscapeText' be the best wording, or should we more closely follow the naming 'PercentEncoded' from QUrl, see: https://doc.qt.io/qt-5/qurl.html#toPercentEncoding
If it does percent encoding, I think PercentEncoded makes the most sense.
Git commit b0055e8476bb5d9a48e317230ce8becc60cf78af by Dominik Haumann. Committed on 21/01/2020 at 17:33. Pushed by dhaumann into branch 'master'. Variable expansion: Add variable PercentEncoded Summary: This can be used to encode the input text such that it can be used in URIs. This is useful e.g. for the external tool "Google Selected Text", where '&' and similar characters are problematic in the url. Test Plan: make && make test Reviewers: cullmann Reviewed By: cullmann Subscribers: kwrite-devel, kde-frameworks-devel Tags: #kate, #frameworks Differential Revision: https://phabricator.kde.org/D26812 M +4 -0 autotests/src/variable_test.cpp M +5 -0 src/utils/katevariableexpansionmanager.cpp https://commits.kde.org/ktexteditor/b0055e8476bb5d9a48e317230ce8becc60cf78af
Git commit a07dceabbb02947f612bdee69da95e6bdb1de89a by Dominik Haumann. Committed on 21/01/2020 at 18:01. Pushed by dhaumann into branch 'external-tools-bug-416320'. Fix External Tool "Google Selected Text" ...by using %{PercentEncoded:...} to make sure the text is properly usable in the URI passed to the browser. This will not be backported to 19.12, since the KTextEditor framework only gained PercentEncoded in version 5.67. FIXED-IN: 20.04 M +1 -1 addons/externaltools/defaultexternaltoolsrc https://invent.kde.org/kde/kate/commit/a07dceabbb02947f612bdee69da95e6bdb1de89a
Git commit a07dceabbb02947f612bdee69da95e6bdb1de89a by Dominik Haumann. Committed on 21/01/2020 at 18:01. Pushed by scmsync into branch 'external-tools-bug-416320'. Fix External Tool "Google Selected Text" ...by using %{PercentEncoded:...} to make sure the text is properly usable in the URI passed to the browser. This will not be backported to 19.12, since the KTextEditor framework only gained PercentEncoded in version 5.67. FIXED-IN: 20.04 M +1 -1 addons/externaltools/defaultexternaltoolsrc https://commits.kde.org/kate/a07dceabbb02947f612bdee69da95e6bdb1de89a
Git commit d198c37cdb36f1d2f8f93610dcac4d26482e8bec by Dominik Haumann. Committed on 21/01/2020 at 18:06. Pushed by dhaumann into branch 'work-fix-bug-416509'. Fix External Tool "Google Selected Text" ...by using %{PercentEncoded:...} to make sure the text is properly usable in the URI passed to the browser. This will not be backported to 19.12, since the KTextEditor framework only gained PercentEncoded in version 5.67. FIXED-IN: 20.04 M +1 -1 addons/externaltools/defaultexternaltoolsrc https://invent.kde.org/kde/kate/commit/d198c37cdb36f1d2f8f93610dcac4d26482e8bec
Git commit d198c37cdb36f1d2f8f93610dcac4d26482e8bec by Dominik Haumann. Committed on 21/01/2020 at 18:06. Pushed by scmsync into branch 'work-fix-bug-416509'. Fix External Tool "Google Selected Text" ...by using %{PercentEncoded:...} to make sure the text is properly usable in the URI passed to the browser. This will not be backported to 19.12, since the KTextEditor framework only gained PercentEncoded in version 5.67. FIXED-IN: 20.04 M +1 -1 addons/externaltools/defaultexternaltoolsrc https://commits.kde.org/kate/d198c37cdb36f1d2f8f93610dcac4d26482e8bec