Skip to content
Snippets Groups Projects
Commit c41c03f3 authored by andi's avatar andi
Browse files

cleanID UTF8 patch

darcs-hash:20050117192112-9977f-084e54a393e8ff0af3954e3a51b8072931529f9b.gz
parent 87a1de9a
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@
require_once("conf/dokuwiki.php");
require_once("inc/io.php");
require_once('inc/utf8.php');
//set up error reporting to sane values
error_reporting(E_ALL ^ E_NOTICE);
......@@ -392,32 +393,41 @@ function cleanID($id){
global $conf;
global $lang;
$id = trim($id);
$id = strtolower($id);
$id = utf8_strtolower($id);
//alternative namespace seperator
$id = strtr($id,';',':');
if($conf['useslash']) $id = strtr($id,'/',':');
//FIXME use config to ask for deaccenting
$id = utf8_deaccent($id,-1);
//remove specials (only ascii specials are removed)
$id = preg_replace('#[ !"§$%&()\[\]{}\\?`\'\#~*+=,<>\|^°@µ¹²³¼½¬]#u','_',$id);
/* DELETEME legacy code
if(!$conf['localnames']){
if($lang['encoding'] == 'iso-8859-15'){
// replace accented chars with unaccented ones
// this may look strange on your terminal - just don't touch
$id = strtr(
strtr($id,
'',
'ŠŽšžŸÀÁÂÃÅÇÈÉÊËÌÍÎÏÑÒÓÔÕØÙÚÛÝàáâãåçèéêëìíîïñòóôõøùúûýÿ',
'szszyaaaaaceeeeiiiinooooouuuyaaaaaceeeeiiiinooooouuuyy'),
array('' => 'th', '' => 'th', '' => 'dh', '' => 'dh', '' => 'ss',
'' => 'oe', '' => 'oe', '' => 'ae', '' => 'ae', '' => 'u',
'' => 'ue', '' => 'oe', '' => 'ae', '' => 'ue', '' => '',
'' => 'ae'));
array('Þ' => 'th', 'þ' => 'th', 'Ð' => 'dh', 'ð' => 'dh', 'ß' => 'ss',
'Œ' => 'oe', 'œ' => 'oe', 'Æ' => 'ae', 'æ' => 'ae', 'µ' => 'u',
'ü' => 'ue', 'ö' => 'oe', 'ä' => 'ae', 'Ü' => 'ue', 'Ö' => 'ö',
'Ä' => 'ae'));
}
$WORD = 'a-z';
}else{
$WORD = '\w';
}
//special chars left will be converted to _
$id = preg_replace('#[^'.$WORD.'0-9:\-\.]#','_',$id);
*/
//clean up
$id = preg_replace('#__#','_',$id);
$id = preg_replace('#:+#',':',$id);
$id = trim($id,':._-');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment