diff -purN pathfilter/README.txt pathfilter-2.0-auto-internal/README.txt
--- pathfilter/README.txt	2009-09-27 09:07:48.000000000 -0700
+++ pathfilter-2.0-auto-internal/README.txt	2009-10-01 22:04:16.000000000 -0700
@@ -43,6 +43,10 @@ if you change an alias for any pathfilte
    absolute URLs (default) paths (relative to the docuemnt root) on the input
    format filter configuration page.
 
+   In Addition, you may automatically have your URLs "internalized" as needed 
+   by enablinging the "Enable automatic URL processing for attributes" option in
+   the same format filter configuration page.
+
 -----------------------
   USE WITH TINYMCE [3]
 -----------------------
@@ -88,4 +92,4 @@ to '<other>' in the 'Insert/Edit link' p
 [2] The "empty cache" link provided by the Devel module
     (http://drupal.org/project/devel) is a convenient way to accomplish this.
 [3] http://drupal.org/project/tinymce
-[4] http://drupal.org/project/fckeditor
\ No newline at end of file
+[4] http://drupal.org/project/fckeditor
diff -purN pathfilter/pathfilter.module pathfilter-2.0-auto-internal/pathfilter.module
--- pathfilter/pathfilter.module	2009-09-27 09:07:48.000000000 -0700
+++ pathfilter-2.0-auto-internal/pathfilter.module	2009-10-01 23:09:11.000000000 -0700
@@ -17,7 +17,13 @@
  * Credits:   
  * @author Ray Zimmerman (drupal.org user "RayZ")
  * @author Tom Kirkpatrick (drupal.org user "mrfelton"), www.kirkdesigns.co.uk
+ * @author George Montana Harkin (drupal.org user "harking") Auto internalization
+ * @author Shayne Huddleston (shayne.huddleston@oregonstate.edu) Fix to auto internailze all node fields
  */
+global $pathfilter_replacement_patterns;
+$pathfilter_replacement_patterns = array();
+$pathfilter_replacement_patterns[] = '/(["\'])(internal):([^"#\?\']+)\??([^"#\']+)?#?([^"\']+)?\1/';
+$pathfilter_replacement_patterns[] = '/(["\'])(files):([^"\']+)\1/';
 
 /**
  * Implementation of hook_filter_tips().
@@ -63,15 +69,11 @@ function pathfilter_filter($op, $delta =
         // The actual filtering is performed here. The supplied text should be
         // returned, once any necessary substitutions have taken place.
         case 'process':
-          $patterns = array();
-          $replacement = array();
-          $patterns[] = '/(["\'])(internal):([^"#\?\']+)\??([^"#\']+)?#?([^"\']+)?\1/';
-          $patterns[] = '/(["\'])(files):([^"\']+)\1/';
-          
+          global $pathfilter_replacement_patterns;
           // use the 'currying' technique to allow us to pass the format into
           // the callback function.
-          $callback = _pathfilter_curry(_pathfilter_process, 2);
-          return preg_replace_callback($patterns, $callback($format), $text);
+          $callback = _pathfilter_curry(_pathfilter_process, 3);
+          return preg_replace_callback($pathfilter_replacement_patterns, $callback($format, TRUE), $text);
 
         // Filter settings for pathfilter.
         case 'settings':
@@ -104,10 +106,10 @@ function _pathfilter_curry($func, $arity
   ");
 }
 
-function _pathfilter_process($format, $matches) {
+function _pathfilter_process($format, $convert_to_alias = TRUE, $matches) {
   switch ($matches[2]) {
     case 'internal':
-      return _pathfilter_process_internal($format, $matches);
+      return _pathfilter_process_internal($format, $convert_to_alias, $matches); //Converts to alias form.
       break;
       
     case 'files':
@@ -115,18 +117,31 @@ function _pathfilter_process($format, $m
   }
 }
 
-function _pathfilter_process_internal($format, $matches) {
+function _pathfilter_process_internal($format, $convert_to_alias, $matches) {
   $absolute = variable_get('pathfilter_link_absolute_'. $format, 1) ? TRUE : FALSE;
+  // If we are going to convert our output to the aliased version ($convert_to_alias is set to TRUE), 
+  // We need to pass 'alias' => true into url to tell it to not pass our URL through
+  // drupal_get_path_alias() thus keeping our 'node/#' format.
   if (module_exists('i18n')) {
     if (preg_match('/(node\/([0-9]+))$/', $matches[3], $match)) {
       // if we have a drupal node url, ensure we get the translated url alias
       $languages = language_list('enabled');
       $languages = $languages[1];
       $language = $languages[i18n_node_get_lang($match[2])];
-      $link = url($match[1], array('language' => $language, 'query' => $matches[4], 'fragment' => $matches[5], 'absolute' => $absolute ));
+      $link = url($match[1], array(
+        'query' => $matches[4], 
+        'fragment' => $matches[5], 
+        'absolute' => $absolute, 
+        'alias' => !$convert_to_alias,
+        'language' => $language ));
     }
   }
-  $link = $link? $link : url($matches[3], array('query' => $matches[4], 'fragment' => $matches[5], 'absolute' => $absolute ));
+  $link = $link? $link : 
+    url($matches[3], array(
+      'query' => $matches[4], 
+      'fragment' => $matches[5], 
+      'absolute' => $absolute,
+      'alias' => !$convert_to_alias ));
   return $matches[1] . $link . $matches[1];
 }
 
@@ -152,5 +167,174 @@ function _pathfilter_settings($format) {
     '#default_value' => variable_get('pathfilter_link_absolute_'. $format, 1),
     '#description' => t('Should internal paths be transformed to absolute URLs, such as %absolute_url or absolute paths, like %absolute_path. Note that your changes may not appear until the cache has been cleared.', array('%absolute_url' => 'http://www.example.com/my-page', '%absolute_path' => '/my-page')),
   );
+  $form['pathfilter']['pathfilter_process_all'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enable automatic url processing for attributes.'),
+    '#default_value' => variable_get('pathfilter_process_all', 1),
+    '#description' => t('When this option is enabled, all %element_list elements will automatically have the servername and base path of their src, href, and action urls replaced with %internal. On editing of these elements, all instances of %internal will be replaced with the site\'s base path (%current_base_path).', array('%element_list' => '<img>, <a>, <script>, <object>, and <form>', '%internal' => '\'internal:\'', '%current_base_path' => base_path())),
+  );
   return $form;
-}
\ No newline at end of file
+}
+
+/**
+ * Modifies submitted node body values. Replaces base_path() in images, hrefs, 
+ * etc with 'internal:' on save. When editing a node, the body's 'internal:' 
+ * strings are replaced with 'base_path()'.
+ */
+function pathfilter_nodeapi( &$node, $op )
+{
+  switch ($op) {
+  case 'prepare':
+    // Convert "internal:" and "files:" back into full URL of site for editing.
+    // We convert back into 'node/#' if possible to keep from breaking URLs when an
+    // alias changes
+    _pathfilter_replace_links($node, '_pathfilter_replace_internal');
+    break;
+  case 'presave':
+    /** We do more when we look for what to replace with 'internal:'
+     * - Only want to replace items that are links, not text or data
+     * - Check to see if they specified the hostname of the server */
+    _pathfilter_replace_links($node, '_pathfilter_internalize');
+    break;
+  }
+}
+
+
+/**
+ * Replaces the links in select node properties (body, teaser, and any 
+ * textfields that have formatting defined for them)
+ *
+ * $node      : StdClass Object
+ * $func_name : String           Can be either _pathfilter_normalize_and_interalize or _pathfilter_replace_internal
+ *                               both functions replace links, one is before saving and one is 
+ *                               before viewing
+ */
+function _pathfilter_replace_links( &$node, $func_name ){
+
+  // If we have our pathfilter variable defined let's replace otherwise bail out.
+  if (variable_get('pathfilter_process_all', 1)) {
+
+    // Let's get all the pathfilters we have defined and their corresponding formats.
+    $result = db_query("SELECT format FROM {filters} WHERE module = 'pathfilter'"); 
+    while ($row = db_fetch_object($result)) {
+      $defined_formats[] = $row->format;
+    }
+
+    // Iterate through our objects properties looking for body, teaser, and any fields that have
+    // formatting defined for them.
+    foreach($node as $key => &$value) {
+      //if this is the body or teaser lets run our replaces
+      if ($key == "body" || $key == "teaser") {
+        if (in_array($node->format, $defined_formats)) {
+          $func_name($node->format, $value);
+        }
+      }
+      elseif (is_array($value)) { 
+        // Look at the rest of the fields...if they have a format from our defined formats list 
+        // and we have a value that is a string run our replace...otherwise ignore them
+        if (!empty($value[0]['format']) && in_array($value[0]['format'], $defined_formats) && 
+          !empty($value[0]['value']) && is_string($value[0]['value'])) {
+            $func_name($value[0]['format'], $value[0]['value']);
+        }
+      }
+    }
+  }
+}
+
+
+/**
+ * Replaces the internal: and files: in elements with the url for it
+ */
+function _pathfilter_replace_internal( $format, &$text ){
+  global $pathfilter_replacement_patterns;
+  // use the 'currying' technique to allow us to pass the format into
+  // the callback function.
+  $callback = _pathfilter_curry(_pathfilter_process, 3);
+  $text = preg_replace_callback($pathfilter_replacement_patterns, $callback($format, FALSE), $text); //Converts to non-aliased form.
+}
+
+/**
+ * Internalizes all urls in a string automatically, doing the user's job for them.
+ */
+function _pathfilter_internalize( $format, &$item ) {
+  // First we find all of the items that look like they need to be replaced.
+  $pattern = '/(<img|<a|<script|<object|<form)[^\>]*>/i';
+  preg_match_all( $pattern, $item, $matches );
+  // Then we normalize the links of the items that matched and do
+  // 'files:' replacement and then 'internal:' replacement.
+  foreach ( $matches[0] as $match ) {
+    // Obtain the URL out of the html tag.
+    preg_match( '/(src=|href=|action=)(\'|")([^\'"]*)(\'|"|>)/', $match, $url );
+    // Do replacement with 'files:' if appropriate, 'internal:' otherwise.
+    $base_files_url_re = _pathfilter_base_files_url_re();
+    $replaced_path = preg_replace( $base_files_url_re, 'files:', $url[3], 1 );
+    if ($replaced_path == $url[3]) {
+      // 'files:' was not found, try 'internal:'. 
+      $base_url_re = _pathfilter_base_url_re();
+      $replaced_path = preg_replace( $base_url_re, 'internal:', $url[3], 1 );
+    }
+
+    // Update original string with changes, if needed.
+    if ($replaced_path != $url[3]) { 
+      $item = preg_replace( '/(src=|href=|action=)(\'|")('.preg_quote($url[3], '/').')(\'|"|>)/', 
+        '$1$2'.$replaced_path.'$4', 
+        $item, 1);
+    }
+  }
+}
+
+/**
+ * Generates the regular expression that will be used to find a url that should
+ * have 'internal:'.
+ */
+function _pathfilter_base_url_re() {
+  static $base_url_re;
+  if ($base_url_re != '') {
+    return $base_url_re;
+  }
+
+  global $base_url;
+  $base_path = base_path();
+
+  if ($base_path != '/') {
+    $tmp_base_url = str_replace($base_path, '', $base_url.'/');
+  } else {
+    $tmp_base_url = $base_url;
+  }
+
+  $base_url_re = '/^('.preg_quote($tmp_base_url, '/').')?'.preg_quote($base_path, '/').'/';
+  return $base_url_re;
+}
+
+/**
+ * Generates the regular expression that will be used to find a url that should
+ * have 'files:'.
+ */
+function _pathfilter_base_files_url_re() {
+  static $base_files_url_re;
+  if ($base_files_url_re != '') {
+    return $base_files_url_re;
+  }
+
+  //Taken from file_create_url() http://api.drupal.org/api/function/file_create_url
+  switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
+    case FILE_DOWNLOADS_PUBLIC:
+      $files_url = file_directory_path() .'/';
+      break;
+    case FILE_DOWNLOADS_PRIVATE:
+      $files_url = 'system/files/';
+      break;
+  }
+
+  global $base_url;
+  $base_path = base_path();
+
+  if ($base_path != '/') {
+    $tmp_base_url = str_replace($base_path, '', $base_url.'/');
+  } else {
+    $tmp_base_url = $base_url;
+  }
+
+  $base_files_url_re = '/^('.preg_quote($tmp_base_url, '/').')?'.preg_quote($base_path.$files_url, '/').'/';
+  return $base_files_url_re;
+}
