changed markdown/showdown to support codepot-aware anchors
This commit is contained in:
		| @ -212,6 +212,12 @@ usericon_dir = "@DEPOTDIR@/usericons" | |||||||
| ;------------------------------------------------------------------------------ | ;------------------------------------------------------------------------------ | ||||||
| log_threshold = 0 | log_threshold = 0 | ||||||
|  |  | ||||||
|  | ;------------------------------------------------------------------------------ | ||||||
|  | ; When yes, open a wiki creation page if a non-existent wiki pages is  | ||||||
|  | ; requested | ||||||
|  | ;------------------------------------------------------------------------------ | ||||||
|  | create_missing_wiki = "no" | ||||||
|  |  | ||||||
| ;------------------------------------------------------------------------------ | ;------------------------------------------------------------------------------ | ||||||
| ; When yes, a project member can delete a non-empty project containing | ; When yes, a project member can delete a non-empty project containing | ||||||
| ; wiki pages, file uploads, etc. An empty project can be deleted any time  | ; wiki pages, file uploads, etc. An empty project can be deleted any time  | ||||||
|  | |||||||
| @ -302,11 +302,10 @@ class File extends Controller | |||||||
| 								break; | 								break; | ||||||
| 							} | 							} | ||||||
|  |  | ||||||
| 							if (strpos($_FILES[$fid]['name'], ':') !== FALSE || | 							if (strpbrk($_FILES[$fid]['name'], CODEPOT_DISALLOWED_LETTERS_IN_FILENAME) !== FALSE) | ||||||
| 							    strpos($_FILES[$fid]['name'], '/') !== FALSE) |  | ||||||
| 							{ | 							{ | ||||||
| 								// prevents these letters for wiki creole  | 								// prevents these letters for wiki creole  | ||||||
| 								$status = "error - colon or slash not allowed - {$_FILES[$fid]['name']}"; | 								$status = "error - disallowed character contained - {$_FILES[$fid]['name']}"; | ||||||
| 								break; | 								break; | ||||||
| 							} | 							} | ||||||
|  |  | ||||||
| @ -386,11 +385,10 @@ class File extends Controller | |||||||
| 							break; | 							break; | ||||||
| 						} | 						} | ||||||
|  |  | ||||||
| 						if (strpos($_FILES[$fid]['name'], ':') !== FALSE || | 						if (strpbrk($_FILES[$fid]['name'], CODEPOT_DISALLOWED_LETTERS_IN_FILENAME) !== FALSE) | ||||||
| 							strpos($_FILES[$fid]['name'], '/') !== FALSE) |  | ||||||
| 						{ | 						{ | ||||||
| 							// prevents these letters for wiki creole | 							// prevents these letters for wiki creole | ||||||
| 							$status = "error - colon or slash not allowed - {$_FILES[$fid]['name']}"; | 							$status = "error - disallowed character contained - {$_FILES[$fid]['name']}"; | ||||||
| 							break; | 							break; | ||||||
| 						} | 						} | ||||||
|  |  | ||||||
|  | |||||||
| @ -335,11 +335,10 @@ class Issue extends Controller | |||||||
| 							$d = $this->input->post("issue_new_file_desc_{$i}"); | 							$d = $this->input->post("issue_new_file_desc_{$i}"); | ||||||
| 							if ($d === FALSE || ($d = trim($d)) == '') $d = ''; // description optional | 							if ($d === FALSE || ($d = trim($d)) == '') $d = ''; // description optional | ||||||
|  |  | ||||||
| 							if (strpos($_FILES[$fid]['name'], ':') !== FALSE || | 							if (strpbrk($_FILES[$fid]['name'], CODEPOT_DISALLOWED_LETTERS_IN_FILENAME) !== FALSE) | ||||||
| 							    strpos($_FILES[$fid]['name'], '/') !== FALSE) |  | ||||||
| 							{ | 							{ | ||||||
| 								// prevents these letters for wiki creole  | 								// prevents these letters for wiki creole  | ||||||
| 								$status = "error - colon or slash not allowed - {$_FILES[$fid]['name']}"; | 								$status = "error - disallowed character contained - {$_FILES[$fid]['name']}"; | ||||||
| 								break; | 								break; | ||||||
| 							} | 							} | ||||||
|  |  | ||||||
| @ -545,11 +544,10 @@ class Issue extends Controller | |||||||
| 						$d = $this->input->post("issue_add_file_desc_{$i}"); | 						$d = $this->input->post("issue_add_file_desc_{$i}"); | ||||||
| 						if ($d === FALSE || ($d = trim($d)) == '') $d = '';  | 						if ($d === FALSE || ($d = trim($d)) == '') $d = '';  | ||||||
|  |  | ||||||
| 						if (strpos($_FILES[$fid]['name'], ':') !== FALSE || | 						if (strpbrk($_FILES[$fid]['name'], CODEPOT_DISALLOWED_LETTERS_IN_FILENAME) !== FALSE) | ||||||
| 						    strpos($_FILES[$fid]['name'], '/') !== FALSE) |  | ||||||
| 						{ | 						{ | ||||||
| 							// prevents these letters for wiki creole | 							// prevents these letters for wiki creole | ||||||
| 							$status = "error - colon or slash not allowed - {$_FILES[$fid]['name']}"; | 							$status = "error - disallowed character contained - {$_FILES[$fid]['name']}"; | ||||||
| 							break; | 							break; | ||||||
| 						} | 						} | ||||||
|  |  | ||||||
|  | |||||||
| @ -121,7 +121,7 @@ class Wiki extends Controller | |||||||
| 			} | 			} | ||||||
| 			else if ($link !== NULL) | 			else if ($link !== NULL) | ||||||
| 			{ | 			{ | ||||||
| 				// redirect to  a special link like __WIKI__:projectid:wikiname | 				// redirect to  a special link like __WIKI__:projectid:wikiname, #R1234, #I999 | ||||||
| 				redirect ($link); | 				redirect ($link); | ||||||
| 			} | 			} | ||||||
| 			else | 			else | ||||||
| @ -151,8 +151,7 @@ class Wiki extends Controller | |||||||
| 					else | 					else | ||||||
| 					{ | 					{ | ||||||
| 						$data['project'] = $project; | 						$data['project'] = $project; | ||||||
| 						$data['message'] = sprintf ( | 						$data['message'] = $this->lang->line('WIKI_MSG_NO_SUCH_PAGE') . " - {$name}"; | ||||||
| 							$this->lang->line('WIKI_MSG_NO_SUCH_PAGE'), $name); |  | ||||||
| 						$this->load->view ($this->VIEW_ERROR, $data); | 						$this->load->view ($this->VIEW_ERROR, $data); | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| @ -168,7 +167,7 @@ class Wiki extends Controller | |||||||
|  |  | ||||||
| 	function show ($projectid = '' , $name = '') | 	function show ($projectid = '' , $name = '') | ||||||
| 	{ | 	{ | ||||||
| 		$this->_show_wiki ($projectid, $name, TRUE); | 		$this->_show_wiki ($projectid, $name, CODEPOT_CREATE_MISSING_WIKI); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	function show_r ($projectid = '' , $name = '') | 	function show_r ($projectid = '' , $name = '') | ||||||
| @ -290,9 +289,8 @@ class Wiki extends Controller | |||||||
| 					} | 					} | ||||||
| 					$wiki->attachments = $atts; | 					$wiki->attachments = $atts; | ||||||
|  |  | ||||||
| 					// disallow : # [ ] | | 					if (strpbrk ($wiki->name, CODEPOT_DISALLOWED_LETTERS_IN_WIKINAME) !== FALSE || | ||||||
| 					if (strpbrk ($wiki->name, ':#[]|') !== FALSE || | 					    (!is_null($new_wiki_name) && strpbrk ($new_wiki_name, CODEPOT_DISALLOWED_LETTERS_IN_WIKINAME) !== FALSE)) | ||||||
| 					    (!is_null($new_wiki_name) && strpbrk ($new_wiki_name, ':#[]|') !== FALSE)) |  | ||||||
| 					{ | 					{ | ||||||
| 						$data['message'] = $this->lang->line('WIKI_MSG_NAME_DISALLOWED_CHARS'); | 						$data['message'] = $this->lang->line('WIKI_MSG_NAME_DISALLOWED_CHARS'); | ||||||
| 						$data['wiki'] = $wiki; | 						$data['wiki'] = $wiki; | ||||||
| @ -390,9 +388,7 @@ class Wiki extends Controller | |||||||
| 					} | 					} | ||||||
| 					else if ($wiki == NULL) | 					else if ($wiki == NULL) | ||||||
| 					{ | 					{ | ||||||
| 						$data['message'] =  | 						$data['message'] = $this->lang->line('WIKI_MSG_NO_SUCH_PAGE') . " - {$name}"; | ||||||
| 							$this->lang->line('WIKI_MSG_NO_SUCH_PAGE') .  |  | ||||||
| 							" - {$name}"; |  | ||||||
| 						$this->load->view ($this->VIEW_ERROR, $data); | 						$this->load->view ($this->VIEW_ERROR, $data); | ||||||
| 					} | 					} | ||||||
| 					else | 					else | ||||||
| @ -540,8 +536,7 @@ class Wiki extends Controller | |||||||
| 				} | 				} | ||||||
| 				else if ($wiki === NULL) | 				else if ($wiki === NULL) | ||||||
| 				{ | 				{ | ||||||
| 					$data['message'] = sprintf ( | 					$data['message'] = $this->lang->line('WIKI_MSG_NO_SUCH_PAGE') . " - {$name}"; | ||||||
| 						$this->lang->line('WIKI_MSG_NO_SUCH_PAGE'), $name); |  | ||||||
| 					$this->load->view ($this->VIEW_ERROR, $data); | 					$this->load->view ($this->VIEW_ERROR, $data); | ||||||
| 				} | 				} | ||||||
| 				else | 				else | ||||||
| @ -570,7 +565,7 @@ class Wiki extends Controller | |||||||
| 			    $_FILES[$field_name]['name'] != '') | 			    $_FILES[$field_name]['name'] != '') | ||||||
| 			{ | 			{ | ||||||
| 				$fname = $_FILES[$field_name]['name']; | 				$fname = $_FILES[$field_name]['name']; | ||||||
| 				if (strpos ($fname, ':') !== FALSE) | 				if (strpbrk($fname, CODEPOT_DISALLOWED_LETTERS_IN_FILENAME) !== FALSE) | ||||||
| 				{ | 				{ | ||||||
| 					while ($attno > 0) | 					while ($attno > 0) | ||||||
| 						@unlink ($attachments[$attno--]['fullencpath']); | 						@unlink ($attachments[$attno--]['fullencpath']); | ||||||
| @ -918,7 +913,7 @@ class Wiki extends Controller | |||||||
| 				{ | 				{ | ||||||
| 					$status = 'error - empty name'; | 					$status = 'error - empty name'; | ||||||
| 				} | 				} | ||||||
| 				else if (strpbrk ($wiki->name, ':#[]|') !== FALSE) | 				else if (strpbrk ($wiki->name, CODEPOT_DISALLOWED_LETTERS_IN_WIKINAME) !== FALSE) | ||||||
| 				{ | 				{ | ||||||
| 					$status = 'error - disallowed characters in name'; | 					$status = 'error - disallowed characters in name'; | ||||||
| 				} | 				} | ||||||
| @ -941,11 +936,10 @@ class Wiki extends Controller | |||||||
| 						$fid = "wiki_file_{$i}"; | 						$fid = "wiki_file_{$i}"; | ||||||
| 						if (array_key_exists($fid, $_FILES) && $_FILES[$fid]['name'] != '') | 						if (array_key_exists($fid, $_FILES) && $_FILES[$fid]['name'] != '') | ||||||
| 						{ | 						{ | ||||||
| 							if (strpos($_FILES[$fid]['name'], ':') !== FALSE || | 							if (strpbrk($_FILES[$fid]['name'], CODEPOT_DISALLOWED_LETTERS_IN_FILENAME) !== FALSE) | ||||||
| 							    strpos($_FILES[$fid]['name'], '/') !== FALSE) |  | ||||||
| 							{ | 							{ | ||||||
| 								// prevents these letters for wiki creole  | 								// prevents these letters for wiki creole  | ||||||
| 								$status = "error - colon or slash not allowed - {$_FILES[$fid]['name']}"; | 								$status = "error - disallowed character contained - {$_FILES[$fid]['name']}"; | ||||||
| 								break; | 								break; | ||||||
| 							} | 							} | ||||||
|  |  | ||||||
|  | |||||||
| @ -164,10 +164,10 @@ if ( !function_exists ('codepot_delete_files')) | |||||||
| 	{ | 	{ | ||||||
| 		// Trim the trailing slash | 		// Trim the trailing slash | ||||||
| 		$path = rtrim($path, DIRECTORY_SEPARATOR); | 		$path = rtrim($path, DIRECTORY_SEPARATOR); | ||||||
| 			 |  | ||||||
| 		if ( ! $current_dir = @opendir($path)) | 		if ( ! $current_dir = @opendir($path)) | ||||||
| 			return; | 			return; | ||||||
| 	 |  | ||||||
| 		while(FALSE !== ($filename = @readdir($current_dir))) | 		while(FALSE !== ($filename = @readdir($current_dir))) | ||||||
| 		{ | 		{ | ||||||
| 			if ($filename != "." && $filename != "..") | 			if ($filename != "." && $filename != "..") | ||||||
|  | |||||||
| @ -6,6 +6,6 @@ $lang['WIKI_MORE_NEW_ATTACHMENTS'] = 'Add more'; | |||||||
| $lang['WIKI_MSG_ATTACHMENT_NAME_NO_COLON'] = 'Attachment name containing a colon'; | $lang['WIKI_MSG_ATTACHMENT_NAME_NO_COLON'] = 'Attachment name containing a colon'; | ||||||
| $lang['WIKI_MSG_NAME_DISALLOWED_CHARS'] = 'Wiki name contains disallowed characters'; | $lang['WIKI_MSG_NAME_DISALLOWED_CHARS'] = 'Wiki name contains disallowed characters'; | ||||||
| $lang['WIKI_MSG_NO_PAGES_AVAILABLE'] = 'No wiki pages available'; | $lang['WIKI_MSG_NO_PAGES_AVAILABLE'] = 'No wiki pages available'; | ||||||
| $lang['WIKI_MSG_NO_SUCH_PAGE'] = 'No such wiki page - %s'; | $lang['WIKI_MSG_NO_SUCH_PAGE'] = 'No such wiki page'; | ||||||
| $lang['WIKI_MSG_RESERVED_WIKI_NAME'] = 'Wiki name containing a reserved word - %s'; | $lang['WIKI_MSG_RESERVED_WIKI_NAME'] = 'Wiki name containing a reserved word - %s'; | ||||||
| ?> | ?> | ||||||
|  | |||||||
| @ -6,6 +6,6 @@ $lang['WIKI_MORE_NEW_ATTACHMENTS'] = '첨부파일 추가'; | |||||||
| $lang['WIKI_MSG_ATTACHMENT_NAME_NO_COLON'] = '첨부파일이름에 콜론기호를 포함할 수 없습니다'; | $lang['WIKI_MSG_ATTACHMENT_NAME_NO_COLON'] = '첨부파일이름에 콜론기호를 포함할 수 없습니다'; | ||||||
| $lang['WIKI_MSG_NAME_DISALLOWED_CHARS'] = '위키이름에 허용되지 않는 문자가 포함되어 있습니다'; | $lang['WIKI_MSG_NAME_DISALLOWED_CHARS'] = '위키이름에 허용되지 않는 문자가 포함되어 있습니다'; | ||||||
| $lang['WIKI_MSG_NO_PAGES_AVAILABLE'] = '사용할 수 있는 위키 페이지가 없습니다'; | $lang['WIKI_MSG_NO_PAGES_AVAILABLE'] = '사용할 수 있는 위키 페이지가 없습니다'; | ||||||
| $lang['WIKI_MSG_NO_SUCH_PAGE'] = '위키 페이지를 찾을수 없습니다 - %s'; | $lang['WIKI_MSG_NO_SUCH_PAGE'] = '위키 페이지를 찾을수 없습니다'; | ||||||
| $lang['WIKI_MSG_RESERVED_WIKI_NAME'] = '%s은(는) 사용할 수 없는 위키이름입니다'; | $lang['WIKI_MSG_RESERVED_WIKI_NAME'] = '%s은(는) 사용할 수 없는 위키이름입니다'; | ||||||
| ?> | ?> | ||||||
|  | |||||||
| @ -2,6 +2,14 @@ | |||||||
|   |   | ||||||
| class WikiHelper | class WikiHelper | ||||||
| { | { | ||||||
|  | 	private static $double_hash_table = array ( | ||||||
|  | 		'##P' => '__PROJECT__', | ||||||
|  | 		'##W' => '__WIKI__', | ||||||
|  | 		'##I' => '__ISSUE__', | ||||||
|  | 		'##C' => '__CODE__', | ||||||
|  | 		'##F' => '__FILE__' | ||||||
|  | 	); | ||||||
|  |  | ||||||
| 	function WikiHelper () | 	function WikiHelper () | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| @ -35,8 +43,33 @@ class WikiHelper | |||||||
| 			$link = "file/show/{$projectid}/{$file_name}"; | 			$link = "file/show/{$projectid}/{$file_name}"; | ||||||
| 			return $link; | 			return $link; | ||||||
| 		} | 		} | ||||||
|  | 		else if (preg_match ('/^#P(.+)$/', $name, $matches) == 1) | ||||||
|  | 		{ | ||||||
|  | 			// #Pprojectid -> translate it to a project home | ||||||
|  | 			$project_name = $matches[1]; // no AsciiToHex | ||||||
|  | 			$link = "project/home/{$project_name}"; | ||||||
|  | 			return $link; | ||||||
|  | 		} | ||||||
|  | 		else if (preg_match ('/^#W(.+)$/', $name, $matches) == 1) | ||||||
|  | 		{ | ||||||
|  | 			// #Pprojectid -> translate it to a wiki name | ||||||
|  | 			$wiki_name = $converter->AsciiToHex ($matches[1]); | ||||||
|  | 			$link = "wiki/show/{$projectid}/{$wiki_name}"; | ||||||
|  | 			return $link; | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		if ($this->_is_reserved ($name, TRUE)) | 		$r = $this->double_hash_to_reserved($name); | ||||||
|  | 		if ($r !== FALSE)  | ||||||
|  | 		{ | ||||||
|  | 			$name = $r; | ||||||
|  | 			$reserved = TRUE; | ||||||
|  | 		} | ||||||
|  | 		else  | ||||||
|  | 		{ | ||||||
|  | 			$reserved = $this->_is_reserved ($name, TRUE); | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if ($reserved) | ||||||
| 		{ | 		{ | ||||||
| 			$ex0 = $this->_trans_reserved ($name); | 			$ex0 = $this->_trans_reserved ($name); | ||||||
|  |  | ||||||
| @ -56,6 +89,8 @@ class WikiHelper | |||||||
| 		{ | 		{ | ||||||
| 			$ex = explode (':', $name); | 			$ex = explode (':', $name); | ||||||
| 			$cnt = count($ex); | 			$cnt = count($ex); | ||||||
|  | 			if ($cnt >= 1 && ($r = $this->double_hash_to_reserved($ex[0])) !== FALSE) $ex[0] = $r; | ||||||
|  |  | ||||||
| 			if ($cnt == 2) | 			if ($cnt == 2) | ||||||
| 			{ | 			{ | ||||||
| 				if ($ex[0] == '__LOCALURL__') | 				if ($ex[0] == '__LOCALURL__') | ||||||
| @ -67,14 +102,6 @@ class WikiHelper | |||||||
| 					$ex0 = $this->_trans_reserved ($ex[0]); | 					$ex0 = $this->_trans_reserved ($ex[0]); | ||||||
| 					$ex1 = ($ex[1] == '')? $projectid: $ex[1]; | 					$ex1 = ($ex[1] == '')? $projectid: $ex[1]; | ||||||
|  |  | ||||||
| 					//redirect ("{$ex0}/home/{$ex1}"); |  | ||||||
|  |  | ||||||
| 					//$link->type = $ex0; |  | ||||||
| 					//$link->target = 'home'; |  | ||||||
| 					//$link->projectid = $ex1; |  | ||||||
| 					//if ($link->projectid == NULL) return FALSE; |  | ||||||
| 					//$link->extra = NULL; |  | ||||||
|  |  | ||||||
| 					if ($ex1 == NULL) return FALSE; | 					if ($ex1 == NULL) return FALSE; | ||||||
| 					$link = "{$ex0}/home/{$ex1}"; | 					$link = "{$ex0}/home/{$ex1}"; | ||||||
| 					return $link; | 					return $link; | ||||||
| @ -88,13 +115,6 @@ class WikiHelper | |||||||
| 					$ex0 = $this->_trans_reserved ($ex[0]); | 					$ex0 = $this->_trans_reserved ($ex[0]); | ||||||
| 					$ex1 = ($ex[1] == '')? $projectid: $ex[1]; | 					$ex1 = ($ex[1] == '')? $projectid: $ex[1]; | ||||||
| 					$ex2 = $converter->AsciiToHex ($ex[2]); | 					$ex2 = $converter->AsciiToHex ($ex[2]); | ||||||
| 					//redirect ("{$ex0}/show/{$ex1}/{$ex2}"); |  | ||||||
|  |  | ||||||
| 					//$link->type = $ex0; |  | ||||||
| 					//$link->target = 'show'; |  | ||||||
| 					//$link->projectid = $ex1; |  | ||||||
| 					//if ($link->projectid == NULL) return FALSE; |  | ||||||
| 					//$link->extra = $ex2; |  | ||||||
|  |  | ||||||
| 					if ($ex1 == NULL) return FALSE; | 					if ($ex1 == NULL) return FALSE; | ||||||
| 					$link = "{$ex0}/show/{$ex1}/{$ex2}"; | 					$link = "{$ex0}/show/{$ex1}/{$ex2}"; | ||||||
| @ -110,13 +130,9 @@ class WikiHelper | |||||||
| 					if ($ex[2] == 'file' || $ex[2] == 'history' ||  | 					if ($ex[2] == 'file' || $ex[2] == 'history' ||  | ||||||
| 					    $ex[2] == 'blame' || $ex[2] == 'diff') | 					    $ex[2] == 'blame' || $ex[2] == 'diff') | ||||||
| 					{ | 					{ | ||||||
|  | 						// __CODE__|project001|file|file001.txt | ||||||
|  |  | ||||||
| 						$ex3 = $converter->AsciiToHex ($ex[3]); | 						$ex3 = $converter->AsciiToHex ($ex[3]); | ||||||
| 						//redirect ("{$ex0}/{$ex[2]}/{$ex1}/{$ex3}"); |  | ||||||
| 						//$link->type = $ex0; |  | ||||||
| 						//$link->target = $ex[2]; |  | ||||||
| 						//$link->projectid = $ex1; |  | ||||||
| 						//if ($link->projectid == NULL) return FALSE; |  | ||||||
| 						//$link->extra = $ex3; |  | ||||||
|  |  | ||||||
| 						if ($ex1 == NULL) return FALSE; | 						if ($ex1 == NULL) return FALSE; | ||||||
| 						$link = "{$ex0}/{$ex[2]}/{$ex1}/{$ex3}"; | 						$link = "{$ex0}/{$ex[2]}/{$ex1}/{$ex3}"; | ||||||
| @ -137,11 +153,6 @@ class WikiHelper | |||||||
| 				{ | 				{ | ||||||
| 					// __WIKI__:projectid:wikiname:attachment | 					// __WIKI__:projectid:wikiname:attachment | ||||||
|  |  | ||||||
| 					//$link->type = $this->_trans_reserved ($ex[0]); |  | ||||||
| 					//$link->target = 'attachment0'; |  | ||||||
| 					//$link->projectid = ($ex[1] == '')? $projectid: $ex[1]; |  | ||||||
| 					//$link->extra = $converter->AsciiToHex ("{$link->projectid}:{$ex[2]}:{$ex[3]}"); |  | ||||||
|  |  | ||||||
| 					$ex0 = $this->_trans_reserved ($ex[0]); | 					$ex0 = $this->_trans_reserved ($ex[0]); | ||||||
| 					$ex1 = ($ex[1] == '')? $projectid: $ex[1]; | 					$ex1 = ($ex[1] == '')? $projectid: $ex[1]; | ||||||
| 					$extra = $converter->AsciiToHex ("{$link->projectid}:{$ex[2]}:{$ex[3]}"); | 					$extra = $converter->AsciiToHex ("{$link->projectid}:{$ex[2]}:{$ex[3]}"); | ||||||
| @ -175,12 +186,18 @@ class WikiHelper | |||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
| 		{ | 		{ | ||||||
| 			return substr ($name, 0, 11) == '__PROJECT__' || | 			return substr($name, 0, 11) == '__PROJECT__' || | ||||||
| 			       substr ($name, 0, 8) == '__WIKI__' || | 			       substr($name, 0, 8) == '__WIKI__' || | ||||||
| 			       substr ($name, 0, 8) == '__FILE__' || | 			       substr($name, 0, 8) == '__FILE__' || | ||||||
| 			       substr ($name, 0, 8) == '__CODE__' || | 			       substr($name, 0, 8) == '__CODE__' || | ||||||
| 			       substr ($name, 0, 9) == '__ISSUE__'; | 			       substr($name, 0, 9) == '__ISSUE__'; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	private function double_hash_to_reserved ($name) | ||||||
|  | 	{ | ||||||
|  | 		if (array_key_exists ($name, self::$double_hash_table)) return self::$double_hash_table[$name]; | ||||||
|  | 		return FALSE; | ||||||
|  | 	} | ||||||
| }  | }  | ||||||
| ?> | ?> | ||||||
|  | |||||||
| @ -21,6 +21,9 @@ function load_ini ($file) | |||||||
| 	if (!is_array($cfg)) $cfg = array (); | 	if (!is_array($cfg)) $cfg = array (); | ||||||
|  |  | ||||||
| 	$xcfgs = array ( | 	$xcfgs = array ( | ||||||
|  | 		array ('disallowed_letters_in_filename', 'string', ':#|[]$*/'), | ||||||
|  | 		array ('disallowed_letters_in_wikiname', 'string', ':#|[]$*'), | ||||||
|  |  | ||||||
| 		array ('default_site_language',        'string',     'english'), | 		array ('default_site_language',        'string',     'english'), | ||||||
| 		array ('default_site_name',            'string',     '@PACKAGE@'), | 		array ('default_site_name',            'string',     '@PACKAGE@'), | ||||||
|  |  | ||||||
| @ -79,6 +82,7 @@ function load_ini ($file) | |||||||
|  |  | ||||||
| 		array ('log_threshold',                'integer',     0), | 		array ('log_threshold',                'integer',     0), | ||||||
|  |  | ||||||
|  | 		array ('create_missing_wiki',          'boolean',     FALSE), | ||||||
| 		array ('force_project_delete',         'boolean',     FALSE), | 		array ('force_project_delete',         'boolean',     FALSE), | ||||||
| 		array ('allow_set_time_limit',         'boolean',     FALSE), | 		array ('allow_set_time_limit',         'boolean',     FALSE), | ||||||
| 		array ('signin_for_code_search',       'boolean',     TRUE), | 		array ('signin_for_code_search',       'boolean',     TRUE), | ||||||
| @ -102,7 +106,7 @@ function load_ini ($file) | |||||||
| 		array ('svn_restriction_allowed_subdir_depth_max', 'integer',     0), | 		array ('svn_restriction_allowed_subdir_depth_max', 'integer',     0), | ||||||
|  |  | ||||||
| 		// this item is used by the codepot-user command. | 		// this item is used by the codepot-user command. | ||||||
| 		array ('codepot_user_executor',                    'string',      'root') | 		array ('codepot_user_executor',                    'string',      'root'), | ||||||
| 	); | 	); | ||||||
|  |  | ||||||
| 	foreach ($xcfgs as $x) | 	foreach ($xcfgs as $x) | ||||||
|  | |||||||
| @ -72,7 +72,12 @@ function getDefaultOpts(simple) { | |||||||
|       default: false, |       default: false, | ||||||
|       describe: 'Prevents weird effects in live previews due to incomplete input', |       describe: 'Prevents weird effects in live previews due to incomplete input', | ||||||
|       type: 'boolean' |       type: 'boolean' | ||||||
|     } |     }, | ||||||
|  |  | ||||||
|  |     // codepot  | ||||||
|  |     codepotImageBase: '', | ||||||
|  |     codepotLinkBase: '' | ||||||
|  |     // end codepot | ||||||
|   }; |   }; | ||||||
|   if (simple === false) { |   if (simple === false) { | ||||||
|     return JSON.parse(JSON.stringify(defaultOptions)); |     return JSON.parse(JSON.stringify(defaultOptions)); | ||||||
| @ -1121,6 +1126,20 @@ showdown.subParser('anchors', function (text, options, globals) { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     url = showdown.helper.escapeCharacters(url, '*_', false); |     url = showdown.helper.escapeCharacters(url, '*_', false); | ||||||
|  |  | ||||||
|  |     // codepot | ||||||
|  |     var front2 = url.substr(0, 2); | ||||||
|  |     var front3 = url.substr(0, 3); | ||||||
|  |  | ||||||
|  |     if (front2 == '#P' || front2 == '#I' || front2 == '#C' || front2 == '#R' || front2 == '#F' || front2 == '#W') | ||||||
|  |     { | ||||||
|  |         url = options.codepotLinkBase + codepot_string_to_hex(url); | ||||||
|  |     } | ||||||
|  |     else if (front3 == '##P' || front3 == '##W' || front3 == '##I' || front3 == '##C' || front3 == '##F') | ||||||
|  |     { | ||||||
|  |         url = options.codepotLinkBase + codepot_string_to_hex(url); | ||||||
|  |     } | ||||||
|  |     // end codepot | ||||||
|     var result = '<a href="' + url + '"'; |     var result = '<a href="' + url + '"'; | ||||||
|  |  | ||||||
|     if (title !== '' && title !== null) { |     if (title !== '' && title !== null) { | ||||||
| @ -1633,6 +1652,7 @@ showdown.subParser('githubCodeBlocks', function (text, options, globals) { | |||||||
|     codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines |     codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines | ||||||
|     codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace |     codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace | ||||||
|  |  | ||||||
|  |     // prettyprint lang- added for codepot | ||||||
|     codeblock = '<pre><code' + (language ? ' class="' + language + ' language-' + language + ' prettyprint lang-' + language + '"' : '') + '>' + codeblock + end + '</code></pre>'; |     codeblock = '<pre><code' + (language ? ' class="' + language + ' language-' + language + ' prettyprint lang-' + language + '"' : '') + '>' + codeblock + end + '</code></pre>'; | ||||||
|  |  | ||||||
|     return showdown.subParser('hashBlock')(codeblock, options, globals); |     return showdown.subParser('hashBlock')(codeblock, options, globals); | ||||||
| @ -2510,11 +2530,12 @@ if (typeof module !== 'undefined' && module.exports) { | |||||||
| //# sourceMappingURL=showdown.js.map | //# sourceMappingURL=showdown.js.map | ||||||
|  |  | ||||||
|  |  | ||||||
|  | // codepot | ||||||
| function showdown_render_wiki_with_input_text (input_text, outputid, linkbase, imgbase, raw) | function showdown_render_wiki_with_input_text (input_text, outputid, linkbase, imgbase, raw) | ||||||
| { | { | ||||||
| 	var sd = new showdown.Converter ({ | 	var sd = new showdown.Converter ({ | ||||||
| 		omitExtraWLInCodeBlocks: false, | 		omitExtraWLInCodeBlocks: false, | ||||||
| 		noHeaderId: true, | 		noHeaderId: false, | ||||||
| 		prefixHeaderId: false, | 		prefixHeaderId: false, | ||||||
| 		parseImgDimensions: true, | 		parseImgDimensions: true, | ||||||
| 		headerLevelStart: 1, | 		headerLevelStart: 1, | ||||||
| @ -2524,7 +2545,10 @@ function showdown_render_wiki_with_input_text (input_text, outputid, linkbase, i | |||||||
| 		tables: true, | 		tables: true, | ||||||
| 		tablesHeaderId: false, | 		tablesHeaderId: false, | ||||||
| 		ghCodeBlocks: true, | 		ghCodeBlocks: true, | ||||||
| 		tasklists: true | 		tasklists: true, | ||||||
|  |  | ||||||
|  | 		codepotLinkBase: linkbase, | ||||||
|  | 		codepotImgBase: imgbase | ||||||
| 	}); | 	}); | ||||||
|  |  | ||||||
| 	function decodeEntities(str) | 	function decodeEntities(str) | ||||||
| @ -2547,3 +2571,4 @@ function showdown_render_wiki (inputid, outputid, linkbase, imgbase, raw) | |||||||
| 	var input = document.getElementById(inputid); | 	var input = document.getElementById(inputid); | ||||||
| 	return showdown_render_wiki_with_input_text (input.innerHTML, outputid, linkbase, imgbase, raw); | 	return showdown_render_wiki_with_input_text (input.innerHTML, outputid, linkbase, imgbase, raw); | ||||||
| } | } | ||||||
|  | // end codepot | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user