Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commits (2)
/* Hexadecimal encode/decode (e.g. URL encode/decode) functions */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* See the GNU Lesser General Public License for more details: lgpl.txt or *
* http://www.fsf.org/copyleft/lesser.html *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
#include "hex.h"
#include "genwrap.h"
#include "gen_defs.h"
char* hex_encode(char esc, const char* src, char* chars, char* dest, size_t size)
{
char* result = dest;
char* end = dest + (size - 1);
while(*src != '\0' && dest < end) {
if((*src == esc || strchr(chars, *src) != NULL) && dest + 3 < end)
dest += sprintf(dest, "%c%2X", esc, *src);
else
*(dest++) = *src;
src++;
}
*end = '\0';
return result;
}
char* hex_decode(char esc, char* str)
{
char* src = str;
char* dest = str;
while(*src != '\0') {
if(*src == esc && IS_HEXDIGIT(*(src + 1)) && IS_HEXDIGIT(*(src + 2))) {
src++;
*dest = HEX_CHAR_TO_INT(*src) << 4;
src++;
*dest |= HEX_CHAR_TO_INT(*src);
} else
*dest = *src;
src++;
dest++;
}
*dest = '\0';
return str;
}
/* Hex encode/decode (e.g. URL encode/decode) functions */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* See the GNU Lesser General Public License for more details: lgpl.txt or *
* http://www.fsf.org/copyleft/lesser.html *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
#ifndef hex_h_
#define hex_h_
#include <stdlib.h> // size_t
#ifdef __cplusplus
extern "C" {
#endif
char* hex_encode(char esc, const char* src, char* chars, char* dest, size_t size);
char* hex_decode(char esc, char* str);
#ifdef __cplusplus
}
#endif
#endif /* Don't add anything after this line */
\ No newline at end of file
......@@ -58,6 +58,7 @@
#include "websrvr.h"
#include "base64.h"
#include "md5.h"
#include "hex.h"
#include "js_rtpool.h"
#include "js_request.h"
#include "js_socket.h"
......@@ -2977,7 +2978,7 @@ static char *get_request(http_session_t * session, char *req_line)
/* Must initialize physical_path before calling is_dynamic_req() */
SAFECOPY(session->req.physical_path,session->req.virtual_path);
unescape(session->req.physical_path);
hex_decode('%', session->req.physical_path);
if (strnicmp(session->req.physical_path,http_scheme,http_scheme_len) == 0) {
scheme = http_scheme;
......
......@@ -164,6 +164,7 @@
</Bscmake>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\encode\hex.c" />
<ClCompile Include="ars.c">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
......