Skip to content

Commit

Permalink
Check in 1.6.13
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlst committed Apr 30, 2020
1 parent 16d6998 commit e449905
Show file tree
Hide file tree
Showing 17 changed files with 390 additions and 167 deletions.
2 changes: 1 addition & 1 deletion LSQUICCOMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f4bfba069bd281258ce72183fd9d274168e9050c
652129e69b0b9eebb0495df0f30b4853b866bff0
34 changes: 33 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,34 @@ freebsdFix()
touch ./needreboot.txt
fi
fi
}


fixPagespeed()
{
PSOLVERSION=1.11.33.4
cat << EOF > ../thirdparty/psol-$PSOLVERSION/include/pagespeed/kernel/base/scoped_ptr.h
/**
* Due the compiling issue, this file was updated from the original file.
*/
#ifndef PAGESPEED_KERNEL_BASE_SCOPED_PTR_H_
#define PAGESPEED_KERNEL_BASE_SCOPED_PTR_H_
#include "base/memory/scoped_ptr.h"
namespace net_instaweb {
template<typename T> class scoped_array : public scoped_ptr<T[]> {
public:
scoped_array() : scoped_ptr<T[]>() {}
explicit scoped_array(T* t) : scoped_ptr<T[]>(t) {}
};
}
#endif
EOF




}

cd `dirname "$0"`
Expand Down Expand Up @@ -509,8 +537,8 @@ if [ "${ISLINUX}" != "yes" ] ; then
sed -i -e "s/psol/ /g" ./build_ols.sh
fi

./build_ols.sh

./build_ols.sh

cd ${CURDIR}

Expand All @@ -524,6 +552,10 @@ cp ../thirdparty/src/brotli/out/*.a ../thirdparty/lib64/
cp ../thirdparty/src//libxml2/.libs/*.a ../thirdparty/lib64/
cp ../thirdparty/src/libmaxminddb/include/* ../thirdparty/include/

if [ "${ISLINUX}" = "yes" ] ; then
fixPagespeed
fi

#special case modsecurity
cd src/modules/modsecurity-ls
ln -sf ../../../../thirdparty/src/ModSecurity .
Expand Down
4 changes: 2 additions & 2 deletions dist/Example/html/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ <h5>To enable optional module uploadprogress</h5>

<form id="upload" action="upload.php" target="resultwindow" method="post" enctype="multipart/form-data">
<div>
<input type="file" name="file1" />
<input type="file" name="file2" />
<input type="file" name="file1" accept="image/jpeg" />
<input type="file" name="file2" accept="image/jpeg" />
<p><input type="submit" /></p>
</div>
</form>
Expand Down
178 changes: 94 additions & 84 deletions dist/Example/html/upload.php
Original file line number Diff line number Diff line change
@@ -1,84 +1,94 @@
<!--
/*****************************************************************************
* Open LiteSpeed is an open source HTTP server. *
* Copyright (C) 2013 - 2018 LiteSpeed Technologies, Inc. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see http://www.gnu.org/licenses/. *
*****************************************************************************/
-->
<html>
<head><style>
body {
font-family: monospace;
font-size: 12px;
}
</style></head>
<body>

<?php
function moveAndShow($src, $dest)
{
if (empty($src)) {
echo "<p>file is empty, not stored.</p>\n";
} else {
rename($src, $dest);
echo "<p>Moved: " . $src . " ====> " . $dest . "<br>";
echo "MD5 : " . md5_file($dest). "<br>";
echo "Size : " . filesize($dest). " bytes</p>\n";
}
}

function disaplyParsedFile($filekey)
{
echo "<p>File : " . $filekey . "<br>";
echo "Name : " . $_POST["{$filekey}_name"] . "<br>";
echo "Type : " . $_POST["{$filekey}_content-type"] . "<br>";
echo "Path : " . $_POST["{$filekey}_path"] . "<br>";
echo "MD5 : " . $_POST["{$filekey}_md5"] . "<br>";
echo "Size : " . $_POST["{$filekey}_size"] . " Bytes<br></p>\n";
}

function displayNoParsedFile($filekey)
{
echo "<p>File : " . $filekey . "<br>";
echo "Name : " . $_FILES["{$filekey}"]['name'] . "<br>";
echo "Type : " . $_FILES["{$filekey}"]['type'] . "<br>";
echo "Path : " . $_FILES["{$filekey}"]['tmp_name'] . "<br>";
echo "Size : " . $_FILES["{$filekey}"]['size'] . "</p>\n";
}




if(empty($_FILES["file1"]))
{
echo "<h1>Request body updated by Parser</h1>\n";

for ($i = 1; $i <= 2; $i++) {
disaplyParsedFile("file{$i}");
$moved_to_path = '/tmp/uploadfile_' . $_POST["file{$i}_name"];
moveAndShow($_POST["file{$i}_path"], $moved_to_path);
}

} else {
echo "<h1>No Parser used</h1>\n";
for ($i = 1; $i <= 2; $i++) {
displayNoParsedFile("file{$i}");
$moved_to_path = '/tmp/uploadfile_' . $_FILES["file{$i}"]["name"];
moveAndShow($_FILES["file{$i}"]["tmp_name"], $moved_to_path);
}
}
?>

</body></html>
<!--
/*****************************************************************************
* Open LiteSpeed is an open source HTTP server. *
* Copyright (C) 2013 - 2020 LiteSpeed Technologies, Inc. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see http://www.gnu.org/licenses/. *
*****************************************************************************/
-->
<html>
<head><style>
body {
font-family: monospace;
font-size: 12px;
}
</style></head>
<body>

<?php
function moveAndShow($src, $dest)
{
if (empty($src)) {
echo "<p>file is empty, not stored.</p>\n";
} else {
$fileType = strtolower(pathinfo($dest,PATHINFO_EXTENSION));
$check = getimagesize($src);
if($check == false) {
echo "<p>file is not jpg file, not stored.</p>\n";
} else {
if($fileType != "jpg") {
echo "<p>file type is not jpg, not stored.</p>\n";
} else {
rename($src, $dest);
echo "<p>Moved: " . $src . " ====> " . $dest . "<br>";
echo "MD5 : " . md5_file($dest). "<br>";
echo "Size : " . filesize($dest). " bytes</p>\n";
}
}
}
}

function disaplyParsedFile($filekey)
{
echo "<p>File : " . $filekey . "<br>";
echo "Name : " . $_POST["{$filekey}_name"] . "<br>";
echo "Type : " . $_POST["{$filekey}_content-type"] . "<br>";
echo "Path : " . $_POST["{$filekey}_path"] . "<br>";
echo "MD5 : " . $_POST["{$filekey}_md5"] . "<br>";
echo "Size : " . $_POST["{$filekey}_size"] . " Bytes<br></p>\n";
}

function displayNoParsedFile($filekey)
{
echo "<p>File : " . $filekey . "<br>";
echo "Name : " . $_FILES["{$filekey}"]['name'] . "<br>";
echo "Type : " . $_FILES["{$filekey}"]['type'] . "<br>";
echo "Path : " . $_FILES["{$filekey}"]['tmp_name'] . "<br>";
echo "Size : " . $_FILES["{$filekey}"]['size'] . "</p>\n";
}




if(empty($_FILES["file1"]))
{
echo "<h1>Request body updated by Parser</h1>\n";

for ($i = 1; $i <= 2; $i++) {
disaplyParsedFile("file{$i}");
$moved_to_path = '/tmp/uploadfile_' . $_POST["file{$i}_name"];
moveAndShow($_POST["file{$i}_path"], $moved_to_path);
}

} else {
echo "<h1>No Parser used</h1>\n";
for ($i = 1; $i <= 2; $i++) {
displayNoParsedFile("file{$i}");
$moved_to_path = '/tmp/uploadfile_' . $_FILES["file{$i}"]["name"];
moveAndShow($_FILES["file{$i}"]["tmp_name"], $moved_to_path);
}
}
?>

</body></html>
29 changes: 24 additions & 5 deletions dist/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1129,14 +1129,33 @@ gen_selfsigned_cert_new()
COMMNAME=`hostname`
SSL_COUNTRY=US
SSL_STATE="New Jersey"
SSL_LOCALITY=Virtual
SSL_ORG=LiteSpeedCommunity
SSL_ORGUNIT=Testing
csr="${SSL_HOSTNAME}.csr"
key="${SSL_HOSTNAME}.key"
cert="${SSL_HOSTNAME}.crt"

openssl req -subj "/CN=${COMMNAME}/O=webadmin/C=US/subjectAltName=DNS.1=${MYIP}/" -new -newkey rsa:2048 -sha256 -days 730 -nodes -x509 -keyout ${key} -out ${cert}

# openssl req -subj "/CN=${COMMNAME}/O=webadmin/C=US/extendedKeyUsage=1.3.6.1.5.5.7.3.1/subjectAltName=DNS.1=${MYIP}/" -new -newkey rsa:2048 -sha256 -days 730 -nodes -x509 -keyout ${key} -out ${cert}
#

cat << EOF > $csr
[req]
prompt=no
distinguished_name=openlitespeed
[openlitespeed]
commonName = ${COMMNAME}
countryName = ${SSL_COUNTRY}
localityName = Virtual
organizationName = LiteSpeedCommunity
organizationalUnitName = Testing
stateOrProvinceName = NJ
emailAddress = mail@${COMMNAME}
name = openlitespeed
initials = CP
dnQualifier = openlitespeed
[server_exts]
extendedKeyUsage=1.3.6.1.5.5.7.3.1
EOF
openssl req -x509 -config $csr -extensions 'server_exts' -nodes -days 820 -newkey rsa:2048 -keyout ${key} -out ${cert}
rm -f $csr
}

gen_selfsigned_cert()
Expand Down
14 changes: 12 additions & 2 deletions src/http/accesslog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ int CustomFormat::parseFormat(const char *psFormat)
char *pItemEnd = NULL;
int state = 0;
int itemId;
int nonstring_items = 0;

memccpy(achBuf, psFormat, 0, 4095);
lstrncpy(achBuf, psFormat, 4096);
pEnd = &achBuf[strlen(achBuf)];
if (strstr(achBuf, "/bin/") || strstr(achBuf, "/tmp/")
|| strstr(achBuf, "/etc/"))
return -1;

while (1)
{
Expand Down Expand Up @@ -283,8 +287,12 @@ int CustomFormat::parseFormat(const char *psFormat)
if (ret != -1)
pItem->m_itemId = ret;
else
{
pItem->m_sExtra.setStr(pBegin, pItemEnd - pBegin);
--nonstring_items;
}
}
++nonstring_items;
push_back(pItem);
}
else
Expand All @@ -295,6 +303,8 @@ int CustomFormat::parseFormat(const char *psFormat)
}
++p;
}
if (nonstring_items == 0)
return -1;
return 0;
}

Expand Down Expand Up @@ -480,7 +490,7 @@ int AccessLog::customLog(HttpSession *pSession, CustomFormat *pLogFmt,
n = fixHttpVer(pSession, p, n);
escape = 1;
}

if (p != pBuf)
{
ret = appendStrNoQuote(pBuf, pBufEnd - pBuf, escape, p, n, pLogger);
Expand Down
Loading

0 comments on commit e449905

Please sign in to comment.