create-prisma-php-app 2.0.0-beta.11 → 2.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bootstrap.php +7 -6
- package/dist/src/Lib/Request.php +5 -0
- package/dist/src/Lib/Validator.php +13 -7
- package/package.json +1 -1
package/dist/bootstrap.php
CHANGED
|
@@ -64,6 +64,7 @@ final class Bootstrap
|
|
|
64
64
|
|
|
65
65
|
Request::$pathname = $contentInfo['pathname'] ? '/' . $contentInfo['pathname'] : '/';
|
|
66
66
|
Request::$uri = $contentInfo['uri'] ? $contentInfo['uri'] : '/';
|
|
67
|
+
Request::$decodedUri = urldecode(Request::$uri);
|
|
67
68
|
|
|
68
69
|
if (is_file(self::$contentToInclude)) {
|
|
69
70
|
Request::$fileToInclude = basename(self::$contentToInclude);
|
|
@@ -818,16 +819,16 @@ try {
|
|
|
818
819
|
}
|
|
819
820
|
|
|
820
821
|
// If there’s caching
|
|
821
|
-
if (isset(Bootstrap::$requestFilesData[Request::$
|
|
822
|
+
if (isset(Bootstrap::$requestFilesData[Request::$decodedUri])) {
|
|
822
823
|
if ($_ENV['CACHE_ENABLED'] === 'true') {
|
|
823
|
-
CacheHandler::serveCache(Request::$
|
|
824
|
+
CacheHandler::serveCache(Request::$decodedUri, intval($_ENV['CACHE_TTL']));
|
|
824
825
|
}
|
|
825
826
|
}
|
|
826
827
|
|
|
827
828
|
// For wire calls, re-include the files if needed
|
|
828
829
|
if (Request::$isWire && !Bootstrap::$secondRequestC69CD) {
|
|
829
|
-
if (isset(Bootstrap::$requestFilesData[Request::$
|
|
830
|
-
foreach (Bootstrap::$requestFilesData[Request::$
|
|
830
|
+
if (isset(Bootstrap::$requestFilesData[Request::$decodedUri])) {
|
|
831
|
+
foreach (Bootstrap::$requestFilesData[Request::$decodedUri]['includedFiles'] as $file) {
|
|
831
832
|
if (file_exists($file)) {
|
|
832
833
|
ob_start();
|
|
833
834
|
require_once $file;
|
|
@@ -852,8 +853,8 @@ try {
|
|
|
852
853
|
MainLayout::$html = TemplateCompiler::injectDynamicContent(MainLayout::$html);
|
|
853
854
|
MainLayout::$html = "<!DOCTYPE html>\n" . MainLayout::$html;
|
|
854
855
|
|
|
855
|
-
if (isset(Bootstrap::$requestFilesData[Request::$
|
|
856
|
-
CacheHandler::saveCache(Request::$
|
|
856
|
+
if (isset(Bootstrap::$requestFilesData[Request::$decodedUri]['fileName']) && $_ENV['CACHE_ENABLED'] === 'true') {
|
|
857
|
+
CacheHandler::saveCache(Request::$decodedUri, MainLayout::$html);
|
|
857
858
|
}
|
|
858
859
|
|
|
859
860
|
echo MainLayout::$html;
|
package/dist/src/Lib/Request.php
CHANGED
|
@@ -22,19 +22,25 @@ final class Validator
|
|
|
22
22
|
/**
|
|
23
23
|
* Validate and sanitize a string.
|
|
24
24
|
*
|
|
25
|
-
* This function converts the input to a string, trims any leading or trailing
|
|
26
|
-
* whitespace, and converts special characters to HTML entities to
|
|
27
|
-
* XSS attacks. If the input is null, an empty string is returned.
|
|
25
|
+
* This function converts the input to a string, trims any leading or trailing
|
|
26
|
+
* whitespace, and optionally converts special characters to HTML entities to
|
|
27
|
+
* prevent XSS attacks. If the input is null, an empty string is returned.
|
|
28
28
|
*
|
|
29
29
|
* @param mixed $value The value to validate and sanitize. This can be of any type.
|
|
30
|
-
* @
|
|
30
|
+
* @param bool $escapeHtml Whether to escape special characters as HTML entities.
|
|
31
|
+
* Defaults to true. Set to false when handling database
|
|
32
|
+
* queries or other non-HTML contexts.
|
|
33
|
+
* @return string The sanitized string. If the input is not a string or null,
|
|
34
|
+
* it is converted to its string representation before sanitization.
|
|
35
|
+
* If the input is null, an empty string is returned.
|
|
31
36
|
*/
|
|
32
|
-
public static function string($value): string
|
|
37
|
+
public static function string($value, bool $escapeHtml = true): string
|
|
33
38
|
{
|
|
34
39
|
// Convert the value to a string if it's not null
|
|
35
40
|
$stringValue = $value !== null ? (string)$value : '';
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
|
|
42
|
+
// If escaping is enabled, apply htmlspecialchars; otherwise, just trim
|
|
43
|
+
return $escapeHtml ? htmlspecialchars(trim($stringValue), ENT_QUOTES, 'UTF-8') : trim($stringValue);
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
/**
|