Move EscapeShell to specific_linux
This commit is contained in:
parent
36b6f70613
commit
ea9813825d
3 changed files with 26 additions and 36 deletions
|
@ -22,35 +22,6 @@ using Platform::internal::GtkIntegration;
|
|||
|
||||
namespace Platform {
|
||||
namespace File {
|
||||
namespace internal {
|
||||
|
||||
QByteArray EscapeShell(const QByteArray &content) {
|
||||
auto result = QByteArray();
|
||||
|
||||
auto b = content.constData(), e = content.constEnd();
|
||||
for (auto ch = b; ch != e; ++ch) {
|
||||
if (*ch == ' ' || *ch == '"' || *ch == '\'' || *ch == '\\') {
|
||||
if (result.isEmpty()) {
|
||||
result.reserve(content.size() * 2);
|
||||
}
|
||||
if (ch > b) {
|
||||
result.append(b, ch - b);
|
||||
}
|
||||
result.append('\\');
|
||||
b = ch;
|
||||
}
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
return content;
|
||||
}
|
||||
|
||||
if (e > b) {
|
||||
result.append(b, e - b);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
void UnsafeOpenUrl(const QString &url) {
|
||||
if (!g_app_info_launch_default_for_uri(
|
||||
|
|
|
@ -11,11 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace Platform {
|
||||
namespace File {
|
||||
namespace internal {
|
||||
|
||||
QByteArray EscapeShell(const QByteArray &content);
|
||||
|
||||
} // namespace internal
|
||||
|
||||
inline QString UrlToLocal(const QUrl &url) {
|
||||
return ::File::internal::UrlToLocalDefault(url);
|
||||
|
|
|
@ -10,7 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/platform/base_platform_info.h"
|
||||
#include "base/platform/linux/base_xcb_utilities_linux.h"
|
||||
#include "platform/linux/linux_desktop_environment.h"
|
||||
#include "platform/linux/file_utilities_linux.h"
|
||||
#include "platform/linux/linux_gtk_integration.h"
|
||||
#include "platform/linux/linux_wayland_integration.h"
|
||||
#include "base/qt_adapters.h"
|
||||
|
@ -63,7 +62,6 @@ extern "C" {
|
|||
#include <iostream>
|
||||
|
||||
using namespace Platform;
|
||||
using Platform::File::internal::EscapeShell;
|
||||
using Platform::internal::WaylandIntegration;
|
||||
using Platform::internal::GtkIntegration;
|
||||
|
||||
|
@ -228,6 +226,32 @@ uint FileChooserPortalVersion() {
|
|||
}
|
||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
|
||||
QByteArray EscapeShell(const QByteArray &content) {
|
||||
auto result = QByteArray();
|
||||
|
||||
auto b = content.constData(), e = content.constEnd();
|
||||
for (auto ch = b; ch != e; ++ch) {
|
||||
if (*ch == ' ' || *ch == '"' || *ch == '\'' || *ch == '\\') {
|
||||
if (result.isEmpty()) {
|
||||
result.reserve(content.size() * 2);
|
||||
}
|
||||
if (ch > b) {
|
||||
result.append(b, ch - b);
|
||||
}
|
||||
result.append('\\');
|
||||
b = ch;
|
||||
}
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
return content;
|
||||
}
|
||||
|
||||
if (e > b) {
|
||||
result.append(b, e - b);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QString EscapeShellInLauncher(const QString &content) {
|
||||
return EscapeShell(content.toUtf8()).replace('\\', "\\\\");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue