Add Chromium-only Blender WebEngine parity work
This commit is contained in:
22
blender-5.2.0/intern/uriconvert/CMakeLists.txt
Normal file
22
blender-5.2.0/intern/uriconvert/CMakeLists.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
# SPDX-FileCopyrightText: 2024 Blender Authors
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
set(INC
|
||||
.
|
||||
)
|
||||
|
||||
set(INC_SYS
|
||||
|
||||
)
|
||||
|
||||
set(SRC
|
||||
uri_convert.cc
|
||||
|
||||
uri_convert.hh
|
||||
)
|
||||
|
||||
set(LIB
|
||||
)
|
||||
|
||||
blender_add_lib(bf_intern_uriconvert "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
42
blender-5.2.0/intern/uriconvert/uri_convert.cc
Normal file
42
blender-5.2.0/intern/uriconvert/uri_convert.cc
Normal file
@@ -0,0 +1,42 @@
|
||||
/* SPDX-FileCopyrightText: 2024 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
|
||||
#include "uri_convert.hh" /* Own include. */
|
||||
|
||||
bool url_encode(const char *str, char *dst, size_t dst_size)
|
||||
{
|
||||
size_t i = 0;
|
||||
|
||||
while (*str && i < dst_size - 1) {
|
||||
char c = char(*str);
|
||||
|
||||
if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') {
|
||||
dst[i++] = *str;
|
||||
}
|
||||
else if (c == ' ') {
|
||||
dst[i++] = '+';
|
||||
}
|
||||
else {
|
||||
if (i + 3 >= dst_size) {
|
||||
/* There is not enough space for %XX. */
|
||||
dst[i] = '\0';
|
||||
return false;
|
||||
}
|
||||
sprintf(&dst[i], "%%%02X", c);
|
||||
i += 3;
|
||||
}
|
||||
++str;
|
||||
}
|
||||
|
||||
dst[i] = '\0';
|
||||
|
||||
if (*str != '\0') {
|
||||
/* Output buffer was too small. */
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
25
blender-5.2.0/intern/uriconvert/uri_convert.hh
Normal file
25
blender-5.2.0/intern/uriconvert/uri_convert.hh
Normal file
@@ -0,0 +1,25 @@
|
||||
/* SPDX-FileCopyrightText: 2024 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#pragma once
|
||||
|
||||
/** \file
|
||||
* \ingroup intern_uri
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Encodes a string into URL format by converting special characters into percent-encoded
|
||||
* sequences.
|
||||
*
|
||||
* This function iterates over the provided C-string and replaces non-alphanumeric characters
|
||||
* (except for '-', '_', '.', '~') with their hexadecimal representations prefixed with '%'.
|
||||
* Spaces are converted into '+', following the conventions of URL encoding for forms
|
||||
* (application/x-www-form-urlencoded).
|
||||
*
|
||||
* \param str: The input C-string to be URL-encoded.
|
||||
* \param dst: The output buffer where the URL-encoded string will be stored.
|
||||
* \param dst_size: The size of the output buffer `dst`.
|
||||
* \return: `true` if encoding was successful, or `false` if the output buffer was insufficient.
|
||||
*/
|
||||
bool url_encode(const char *str, char *dst, size_t dst_size);
|
||||
Reference in New Issue
Block a user