Skip to content

Commit

Permalink
Merge branch hotfix/v8.0.1 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
papacarlo committed Feb 26, 2024
2 parents e30abd0 + cf90cd9 commit 8ca63e5
Show file tree
Hide file tree
Showing 141 changed files with 3,369 additions and 1,686 deletions.
162 changes: 162 additions & 0 deletions .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
name: "CodeQL Scanner"
on:
push:
branches:
- 'master'
- 'release/**'
- 'hotfix/**'
paths-ignore:
- '**/README.md'
- '**/LICENSE'
- '.github/**'
#pull_request:
# branches:
# - 'master'
# - 'release/**'
# - 'hotfix/**'
schedule:
- cron: '00 19 * * 5'

# This job take a lot of time, so if the number of worker
# processes from one branch or one PR exceeds 1, all previous
# running processes will be automatically canceled to avoid the accumulation
# of a large number of concurrent workers
concurrency:
group: codeql-${{ github.event.pull_request.number || github.ref_name }}
cancel-in-progress: true

env:
SOURCE_ROOT: "/build/core"

jobs:
analyze:
name: Analyze
runs-on: ${{ 'ubuntu-latest' }}
container:
image: ${{ matrix.image }}
options: --privileged
volumes:
- /usr/local/lib:/foovolume/android
- /usr/local/share:/foovolume/boost
- /usr/share:/foovolume/dotnet
- /opt:/foovolume/opt
- /opt/hostedtoolcache:/foovolume/tool
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'c-cpp' ]
image: ["ubuntu:20.04"]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- uses: actions/setup-node@v4
with:
node-version: 20

- name: make free space in container
run: |
rm -rf /foovolume/android/android
rm -rf /foovolume/dotnet/dotnet
rm -rf /foovolume/boost/boost
rm -rf /foovolume/opt/ghc
rm -rf /foovolume/tool/*
df -h
# Prepare container environment
# Install some deps
# Set cache restore keys
- name: Prepare environment
id: prepare
shell: bash
env:
TZ: Etc/UTC
run: |
pwd
ls -la
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
echo $TZ > /etc/timezone
apt-get update
apt-get install -y python3 python2 sudo curl jq git
apt-get install -y python || true
rm /usr/bin/python || true
ln -s /usr/bin/python2 /usr/bin/python
mkdir -p /build
git clone --depth 1 \
--single-branch \
--branch ${{ github.base_ref || github.ref_name }} https://github.com/ONLYOFFICE/core.git ${SOURCE_ROOT}
git clone --depth 1 \
--single-branch \
--branch ${{ github.base_ref || github.ref_name }} https://github.com/ONLYOFFICE/build_tools.git /build/build_tools
echo "party-key=$(curl -L -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/ONLYOFFICE/core/commits?per_page=1&path=/Common/3dParty&sha=${{ github.base_ref || github.ref_name }}" | \
jq -r '.[].sha')" >> "$GITHUB_OUTPUT"
echo "qt-key=$(cat /build/build_tools/tools/linux/automate.py | egrep -m1 -o "qt_source_([0-9])?.([0-9])?.([0-9])?")" >> "$GITHUB_OUTPUT"
# Restore 3dParty from cache if cache key is match
- uses: actions/cache/restore@v3
id: restore-3d
with:
path: /build/core/Common/3dParty
key: 3dParty-${{ steps.prepare.outputs.party-key }}

# Restore qt tool from cache if cache key is match
- uses: actions/cache/restore@v3
id: restore-qt
with:
path: /build/build_tools/tools/linux/qt_build
key: qt-${{ steps.prepare.outputs.qt-key }}

# NOTE:
# init codeql with custom source-root dir
# because sources code was checkout with git from cli
# NOT with checkout action
# Also. Init and scan with codeql only if all cache hit
# otherwise will no initialization, just build and cache depends
- name: Initialize CodeQL
if: >
steps.restore-3d.outputs.cache-hit == 'true'
&& steps.restore-qt.outputs.cache-hit == 'true'
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
source-root: ${{ env.SOURCE_ROOT }}

- name: build
shell: bash
run: |
cd /build/build_tools/tools/linux
python3 ./automate.py core
- name: Perform CodeQL Analysis
if: >
steps.restore-3d.outputs.cache-hit == 'true'
&& steps.restore-qt.outputs.cache-hit == 'true'
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"

# Make new 3dParty cache if restore action do not restore any cache
- uses: actions/cache/save@v3
if: steps.restore-3d.outputs.cache-hit != 'true'
id: save-3d
with:
path: /build/core/Common/3dParty
key: 3dParty-${{ steps.prepare.outputs.party-key }}

# Make new qt tool cache if restore action do not restore any cache
- uses: actions/cache/save@v3
if: steps.restore-qt.outputs.cache-hit != 'true'
id: save-qt
with:
path: /build/build_tools/tools/linux/qt_build
key: qt-${{ steps.prepare.outputs.qt-key }}
11 changes: 8 additions & 3 deletions Common/Network/FileTransporter/src/FileTransporter_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ namespace NSNetwork
std::function<void(int)> func_onProgress = nullptr;
};

void EscapeQuotesPS(std::wstring& command)
void EscapeQuotesPS(std::wstring& command, bool isPath)
{
/*
var symbols = [0x22, 0x27, 0x2018, 0x2019, 0x201a, 0x201b, 0x201c, 0x201d, 0x201e, 0x201f];
Expand All @@ -456,6 +456,11 @@ namespace NSNetwork

std::wstring sTmp = L" ";

if (isPath)
{
sTmp[0] = (wchar_t)'\\'; NSStringExt::Replace(command, sTmp, L"/");
}

sTmp[0] = (wchar_t)0x22; NSStringExt::Replace(command, sTmp, L"%22");
sTmp[0] = (wchar_t)0x27; NSStringExt::Replace(command, sTmp, L"%27");
sTmp[0] = (wchar_t)0x2018; NSStringExt::Replace(command, sTmp, L"%E2%80%98");
Expand All @@ -477,8 +482,8 @@ namespace NSNetwork
std::wstring sFileDst = strFileOutput;
std::wstring sFileURL = sFileURLOriginal;

NSStringExt::Replace(sFileDst, L"\\", L"/");
EscapeQuotesPS(sFileURL);
EscapeQuotesPS(sFileDst, true);
EscapeQuotesPS(sFileURL, false);

std::wstring sApp = L"powershell.exe –c \"(new-object System.Net.WebClient).DownloadFile('" + sFileURL + L"','" + sFileDst + L"')\"";
wchar_t* pCommandLine = new wchar_t[sApp.length() + 1];
Expand Down
6 changes: 3 additions & 3 deletions Common/Network/FileTransporter/src/transport_external.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,19 @@ namespace NSNetwork
int nIndexLast = 9;
if (NSProcessEnv::IsPresent(NSProcessEnv::Converter::gc_proxy))
{
sProxy = NSProcessEnv::GetBoolValue(NSProcessEnv::Converter::gc_proxy);
sProxy = NSProcessEnv::GetStringValueA(NSProcessEnv::Converter::gc_proxy);
nargs[nIndexLast++] = "--proxy";
nargs[nIndexLast++] = sProxy.c_str();
}
if (NSProcessEnv::IsPresent(NSProcessEnv::Converter::gc_proxyUser))
{
sProxyIser = NSProcessEnv::GetBoolValue(NSProcessEnv::Converter::gc_proxyUser);
sProxyIser = NSProcessEnv::GetStringValueA(NSProcessEnv::Converter::gc_proxyUser);
nargs[nIndexLast++] = "--proxy-user";
nargs[nIndexLast++] = sProxyIser.c_str();
}
if (NSProcessEnv::IsPresent(NSProcessEnv::Converter::gc_proxyHeader))
{
sProxyHeader = NSProcessEnv::GetBoolValue(NSProcessEnv::Converter::gc_proxyHeader);
sProxyHeader = NSProcessEnv::GetStringValueA(NSProcessEnv::Converter::gc_proxyHeader);
nargs[nIndexLast++] = "--proxy-header";
nargs[nIndexLast++] = sProxyHeader.c_str();
}
Expand Down
56 changes: 56 additions & 0 deletions Common/js/logging.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#ifndef _LOG_FILE_H
#define _LOG_FILE_H

#include <stdio.h>
#define LOG_BUFFER_SIZE 1000

namespace Logging
{
void logBytes(char* name, unsigned char* str, int len)
{
char buffer[LOG_BUFFER_SIZE];
char* name_cur = name;
char* buf_cur = buffer;

while (*name_cur != 0)
{
*buf_cur++ = *name_cur++;
}

*buf_cur++ = ':';
*buf_cur++ = ' ';
*buf_cur++ = '[';

for (int i = 0; i < len; ++i)
{
unsigned char c = str[i];

unsigned char n1 = (unsigned char)(c / 100);
c -= (n1 * 100);

unsigned char n2 = (unsigned char)(c / 10);
c -= (n2 * 10);

if (buf_cur - buffer + 4 >= LOG_BUFFER_SIZE)
{
*buf_cur++ = '\0';
printf("%s\n", buffer);

buf_cur = buffer;
}

*buf_cur++ = (char)('0' + n1);
*buf_cur++ = (char)('0' + n2);
*buf_cur++ = (char)('0' + c);
*buf_cur++ = ',';
}

buf_cur--;
*buf_cur++ = ']';
*buf_cur++ = '\0';

printf("%s\n", buffer);
}
}

#endif // _LOG_FILE_H
22 changes: 12 additions & 10 deletions Common/kernel.pro
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,27 @@ HEADERS += ./kernel_config.h

# BLOCKER
HEADERS += \
./../DesktopEditor/graphics/TemporaryCS.h
./../DesktopEditor/graphics/TemporaryCS.h

SOURCES += \
./../DesktopEditor/graphics/TemporaryCS.cpp
./../DesktopEditor/graphics/TemporaryCS.cpp

# THREAD
core_android:DEFINES += NOT_USE_PTHREAD_CANCEL USE_FILE32API
HEADERS += \
./../DesktopEditor/graphics/BaseThread.h
./../DesktopEditor/graphics/BaseThread.h \
./../DesktopEditor/graphics/BaseThreadMonitor.h

SOURCES += \
./../DesktopEditor/graphics/BaseThread.cpp
./../DesktopEditor/graphics/BaseThread.cpp \
./../DesktopEditor/graphics/BaseThreadMonitor.cpp

# TIMER
HEADERS += \
./../DesktopEditor/graphics/Timer.h
./../DesktopEditor/graphics/Timer.h

SOURCES += \
./../DesktopEditor/graphics/Timer.cpp
./../DesktopEditor/graphics/Timer.cpp

# PATH
HEADERS += ./../DesktopEditor/common/Path.h
Expand Down Expand Up @@ -92,11 +94,11 @@ HEADERS += ./../DesktopEditor/common/ProcessEnv.h
SOURCES += ./../DesktopEditor/common/ProcessEnv.cpp

core_windows {
LIBS += -lRpcrt4
LIBS += -lShell32
LIBS += -lRpcrt4
LIBS += -lShell32
}

core_ios {
OBJECTIVE_SOURCES += ./../DesktopEditor/common/File_ios.mm
LIBS += -framework Foundation
OBJECTIVE_SOURCES += ./../DesktopEditor/common/File_ios.mm
LIBS += -framework Foundation
}
2 changes: 1 addition & 1 deletion DesktopEditor/common/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ namespace NSFile
}

pUnicodeString[lIndexUnicode++] = (WCHAR)(val);
lIndex += 5;
lIndex += 6;
}
}

Expand Down
Loading

0 comments on commit 8ca63e5

Please sign in to comment.