commit b7870c5ac81f9f1ddd2b7f387624269f48bfbece
parent 8252a821b4c370a79f73ce2994f2ea479512d30f
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Sat, 26 Oct 2024 17:48:15 +0200
feat: allow more characters in titles
Diffstat:
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/index.php b/index.php
@@ -100,7 +100,6 @@
);
/* set action to "list", so we return to the main view again */
$action = "list";
- $category = "";
}
?>
diff --git a/lib/helpers.php b/lib/helpers.php
@@ -21,7 +21,7 @@ function gather_get(string $key) {
function validate_input_string(string $in) {
/* Only allows alphanumeric characters and any of "-_. " */
$out = preg_replace(
- "/[^A-Za-z0-9\-\_\.\s]/",
+ "/[^A-Za-z0-9äöüßÄÖÜß\-\_\.\s\;\,\=\@\#]/",
"_",
$in
);
@@ -131,7 +131,10 @@ function page_title(
if (!empty($string)) {
$title = trim((explode(">", $string))[1]);
}
- }
+ }
+
+ /* decode html entities */
+ $title = html_entity_decode($title);
/* return title */
return $title;
@@ -145,7 +148,7 @@ function generate_filename(string $content) {
/* if the first line of the content contains a URL,
* we may use the page title */
$file_link = preg_replace(
- '/^(http(s){0,1}:\/\/[^\s]+)*.*$/',
+ '/^(https{0,1}:\/\/[^\s]+)*.*$/',
'\1',
explode(PHP_EOL, $content)[0]
);
@@ -160,7 +163,7 @@ function generate_filename(string $content) {
if (empty($filename)) {
if (!empty($file_link)) {
$filename = preg_replace(
- '/http(s){0,1}:\/\/(.*)/',
+ '/^https{0,1}:\/\/(.*)$/',
'\1',
$file_link
);
diff --git a/lib/list.php b/lib/list.php
@@ -27,11 +27,11 @@ function list_notes(
if ($filename["link"] !== false) {
?>
<a href="<?php echo $filename["link"]; ?>" target="_blank">
- <strong><?php echo $filename["name"]; ?></strong>
+ <strong><?php echo htmlentities($filename["name"]); ?></strong>
</a><br>
<?php } else { ?>
- <strong><?php echo $filename["name"]; ?></strong><br>
+ <strong><?php echo htmlentities($filename["name"]); ?></strong><br>
<?php } ?>
<!-- date marker -->
@@ -59,7 +59,7 @@ function list_notes(
<input
type="submit"
class="likeanchor"
- value="<?php echo $filename["category"]; ?>"
+ value="<?php echo htmlentities($filename["category"]); ?>"
>
</form>