<?php
- /* URL Passing code to allow links from with in emails */
- /* $Id$ */
- $url_parser_php = true;
+/**
+ * url_parser.php
+ *
+ * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * This code provides various string manipulation functions that are
+ * used by the rest of the Squirrelmail code.
+ *
+ * $Id$
+ */
- function replaceBlock (&$in, $replace, $start, $end) {
- $begin = substr($in,0,$start);
- $end = substr($in,$end,strlen($in)-$end);
- $in = $begin.$replace.$end;
- }
+/*****************************************************************/
+/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/
+/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/
+/*** + Base level indent should begin at left margin, as ***/
+/*** the first line of the function definition below. ***/
+/*** + All identation should consist of four space blocks ***/
+/*** + Tab characters are evil. ***/
+/*** + all comments should use "slash-star ... star-slash" ***/
+/*** style -- no pound characters, no slash-slash style ***/
+/*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/
+/*** ALWAYS USE { AND } CHARACTERS!!! ***/
+/*** + Please use ' instead of ", when possible. Note " ***/
+/*** should always be used in _( ) function calls. ***/
+/*** Thank you for your help making the SM code more readable. ***/
+/*****************************************************************/
+
+function replaceBlock (&$in, $replace, $start, $end) {
+ $begin = substr($in,0,$start);
+ $end = substr($in,$end,strlen($in)-$end);
+ $in = $begin.$replace.$end;
+}
// Having this defined in just one spot could help when changes need
// to be made to the pattern
// $IPMatch = '\[?' . $IPMatch . '(\.' . $IPMatch . '){3}\]?';
//
// Here's enough:
+ global $IP_RegExp_Match, $Host_RegExp_Match, $Email_RegExp_Match;
$IP_RegExp_Match = '\\[?[0-9]{1,3}(\\.[0-9]{1,3}){3}\\]?';
$Host_RegExp_Match = '(' . $IP_RegExp_Match .
'|[0-9a-z]([-.]?[0-9a-z])*\\.[a-z][a-z]+)';
// We don't want to re-initialize this stuff for every line. Save work
// and just do it once here.
+ global $url_parser_url_tokens;
$url_parser_url_tokens = array(
'http://',
'https://',
'gopher://',
'news://');
+ global $url_parser_poss_ends;
$url_parser_poss_ends = array(' ', "\n", "\r", '<', '>', ".\r", ".\n",
'. ', ' ', ')', '(', '"', '<', '>', '.<',
- ']', '[', '{', '}', "\240");
+ ']', '[', '{', '}', "\240", ', ', '. ', ",\n", ",\r");
function parseUrl (&$body)
// Extract URL
$url = substr($body, $target_pos, $end-$target_pos);
+ // Needed since lines are not passed with \n or \r
+ while ( ereg("[,\.]$", $url) ) {
+ $url = substr( $url, 0, -1 );
+ $end--;
+ }
+
// Replace URL with HyperLinked Url, requires 1 char in link
if ($url != '' && $url != $target_token)
{