-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpatch.sh
More file actions
executable file
·75 lines (64 loc) · 2.41 KB
/
Copy pathpatch.sh
File metadata and controls
executable file
·75 lines (64 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# =============================================================================
# Parsedown.php patch script for PHP 8.4
# =============================================================================
# This script applies a patch to the "_bundle/Parsedown_1.7.4/Parsedown.php"
# file to avoid deprecation warning of implicit null param usage in PHP 8.4.
#
# - "Implicitly marking parameter as nullable is deprecated, the explicit
# nullable type must be used instead." thingy.
# =============================================================================
# Ensure to apply the patch to the correct file
HASH_EXPECTED="af4a4b29f38b5a00b003a3b7a752282274c969e42dee88e55a427b2b61a2f38f"
PATH_DIR_ORIGIN="../Parsedown_1.7.4"
PATH_FILE_PHP_ORIGIN="${PATH_DIR_ORIGIN}/Parsedown.php"
PATH_FILE_LICENSE_ORIGIN="${PATH_DIR_ORIGIN}/LICENSE.txt"
HASH_CURRENT=$(shasum -a 256 "$PATH_FILE_PHP_ORIGIN" | awk '{print $1}')
if [ "$HASH_CURRENT" != "$HASH_EXPECTED" ]; then
echo "Hash mismatch!"
echo " Expected: ${HASH_EXPECTED}"
echo " but got : ${HASH_CURRENT}"
fi
# Copy the original file into the current directory
cp "$PATH_FILE_PHP_ORIGIN" ./Parsedown.php
cp "$PATH_FILE_LICENSE_ORIGIN" ./LICENSE.txt
# The patch to apply
PATCH_DATA=$(cat <<'HEREDOC'
--- a/_bundle/Parsedown_1.7.4/Parsedown.php
+++ b/_bundle/Parsedown_1.7.4-patched/Parsedown.php
@@ -2,7 +2,7 @@
#
#
-# Parsedown
+# Parsedown (patched)
# http://parsedown.org
#
# (c) Emanuil Rusev
@@ -17,7 +17,7 @@ class Parsedown
{
# ~
- const version = '1.7.4';
+ const version = '1.7.4-patched';
# ~
@@ -712,7 +712,7 @@ class Parsedown
#
# Setext
- protected function blockSetextHeader($Line, array $Block = null)
+ protected function blockSetextHeader($Line, ?array $Block = null)
{
if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
{
@@ -850,7 +850,7 @@ class Parsedown
#
# Table
- protected function blockTable($Line, array $Block = null)
+ protected function blockTable($Line, ?array $Block = null)
{
if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
{
HEREDOC
)
# Apply the patch with appropriate -p level so that the patched file name is just "Parsedown.php"
echo "$PATCH_DATA" | patch -p3 ./Parsedown.php
shasum -a 256 --tag Parsedown.php > ./Parsedown.php.sha256
echo "Patched file saved as ./Parsedown.php"