1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-22 04:23:01 +00:00

Nuke all usages of utf8_encode, as I misunderstood what it did.

This commit is contained in:
Starbeamrainbowlabs 2018-03-18 16:37:25 +00:00
parent 24efac3c5e
commit 3dc505992d
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
5 changed files with 22 additions and 22 deletions

View file

@ -1189,19 +1189,19 @@ if(!file_exists($paths->pageindex))
// Create a new entry
$newentry = new stdClass();
$newentry->filename = utf8_encode(substr( // Store the filename, whilst trimming the storage prefix
$newentry->filename = substr( // Store the filename, whilst trimming the storage prefix
$pagefilename,
strlen(preg_replace("/^\.\//i", "", $env->storage_prefix)) // glob_recursive trim the ./ from returned filenames , so we need to as well
));
mb_strlen(preg_replace("/^\.\//iu", "", $env->storage_prefix)) // glob_recursive trim the ./ from returned filenames , so we need to as well
);
// Remove the `./` from the beginning if it's still hanging around
if(substr($newentry->filename, 0, 2) == "./")
$newentry->filename = substr($newentry->filename, 2);
$newentry->size = filesize($pagefilename); // Store the page size
$newentry->lastmodified = filemtime($pagefilename); // Store the date last modified
// Todo find a way to keep the last editor independent of the page index
$newentry->lasteditor = utf8_encode("unknown"); // Set the editor to "unknown"
$newentry->lasteditor = "unknown"; // Set the editor to "unknown"
// Extract the name of the (sub)page without the ".md"
$pagekey = utf8_encode(substr($newentry->filename, 0, -3));
$pagekey = mb_substr($newentry->filename, 0, -3);
if(file_exists($env->storage_prefix . $pagekey) && // If it exists...
!is_dir($env->storage_prefix . $pagekey)) // ...and isn't a directory
@ -1388,7 +1388,7 @@ class ids
$nextid++;
// Update the id index
$idindex->$nextid = utf8_encode($pagename);
$idindex->$nextid = $pagename;
// Save the id index
file_put_contents($paths->idindex, json_encode($idindex));
@ -4109,7 +4109,7 @@ class search
public static function index($source)
{
$source = html_entity_decode($source, ENT_QUOTES);
$source_length = strlen($source);
$source_length = mb_strlen($source);
$index = [];
@ -4188,7 +4188,7 @@ class search
$missing_files++;
continue;
}
$pagesource = utf8_encode(file_get_contents($page_filename));
$pagesource = Normalizer::normalize(file_get_contents($page_filename), Normalizer::FORM_C);
$index = self::index($pagesource);
$pageid = ids::getid($pagename);
@ -6560,9 +6560,9 @@ DIFFSCRIPT;
$pageindex->{$env->page}->size = strlen($_POST["content"]);
$pageindex->{$env->page}->lastmodified = time();
if($env->is_logged_in)
$pageindex->{$env->page}->lasteditor = utf8_encode($env->user);
$pageindex->{$env->page}->lasteditor = $env->user;
else // TODO: Add an option to record the user's IP here instead
$pageindex->{$env->page}->lasteditor = utf8_encode("anonymous");
$pageindex->{$env->page}->lasteditor = "anonymous";
$pageindex->{$env->page}->tags = $page_tags;
// A hack to resave the pagedata if the preprocessors have

View file

@ -813,19 +813,19 @@ if(!file_exists($paths->pageindex))
// Create a new entry
$newentry = new stdClass();
$newentry->filename = utf8_encode(substr( // Store the filename, whilst trimming the storage prefix
$newentry->filename = substr( // Store the filename, whilst trimming the storage prefix
$pagefilename,
strlen(preg_replace("/^\.\//i", "", $env->storage_prefix)) // glob_recursive trim the ./ from returned filenames , so we need to as well
));
mb_strlen(preg_replace("/^\.\//iu", "", $env->storage_prefix)) // glob_recursive trim the ./ from returned filenames , so we need to as well
);
// Remove the `./` from the beginning if it's still hanging around
if(substr($newentry->filename, 0, 2) == "./")
$newentry->filename = substr($newentry->filename, 2);
$newentry->size = filesize($pagefilename); // Store the page size
$newentry->lastmodified = filemtime($pagefilename); // Store the date last modified
// Todo find a way to keep the last editor independent of the page index
$newentry->lasteditor = utf8_encode("unknown"); // Set the editor to "unknown"
$newentry->lasteditor = "unknown"; // Set the editor to "unknown"
// Extract the name of the (sub)page without the ".md"
$pagekey = utf8_encode(substr($newentry->filename, 0, -3));
$pagekey = mb_substr($newentry->filename, 0, -3);
if(file_exists($env->storage_prefix . $pagekey) && // If it exists...
!is_dir($env->storage_prefix . $pagekey)) // ...and isn't a directory
@ -1012,7 +1012,7 @@ class ids
$nextid++;
// Update the id index
$idindex->$nextid = utf8_encode($pagename);
$idindex->$nextid = $pagename;
// Save the id index
file_put_contents($paths->idindex, json_encode($idindex));

View file

@ -104,7 +104,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.",
"id": "feature-search",
"lastupdate": 1521389882,
"lastupdate": 1521390977,
"optional": false
},
{
@ -167,7 +167,7 @@
"author": "Starbeamrainbowlabs",
"description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
"id": "page-edit",
"lastupdate": 1518645807,
"lastupdate": 1521390769,
"optional": false
},
{

View file

@ -509,7 +509,7 @@ class search
public static function index($source)
{
$source = html_entity_decode($source, ENT_QUOTES);
$source_length = strlen($source);
$source_length = mb_strlen($source);
$index = [];
@ -588,7 +588,7 @@ class search
$missing_files++;
continue;
}
$pagesource = utf8_encode(file_get_contents($page_filename));
$pagesource = Normalizer::normalize(file_get_contents($page_filename), Normalizer::FORM_C);
$index = self::index($pagesource);
$pageid = ids::getid($pagename);

View file

@ -424,9 +424,9 @@ DIFFSCRIPT;
$pageindex->{$env->page}->size = strlen($_POST["content"]);
$pageindex->{$env->page}->lastmodified = time();
if($env->is_logged_in)
$pageindex->{$env->page}->lasteditor = utf8_encode($env->user);
$pageindex->{$env->page}->lasteditor = $env->user;
else // TODO: Add an option to record the user's IP here instead
$pageindex->{$env->page}->lasteditor = utf8_encode("anonymous");
$pageindex->{$env->page}->lasteditor = "anonymous";
$pageindex->{$env->page}->tags = $page_tags;
// A hack to resave the pagedata if the preprocessors have