Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 13688)
+++ wp-includes/post.php	(working copy)
@@ -790,7 +790,7 @@
 		$wp_post_types = array();
 
 	// Args prefixed with an underscore are reserved for internal use.
-	$defaults = array('label' => false, 'singular_label' => false, 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 'taxonomies' => array(), 'show_ui' => null );
+	$defaults = array('label' => false, 'singular_label' => false, 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 'taxonomies' => array(), 'show_ui' => null, 'permalink_epmask' => EP_NONE );
 	$args = wp_parse_args($args, $defaults);
 	$args = (object) $args;
 
@@ -852,7 +852,7 @@
 		if ( !isset($args->rewrite['with_front']) )
 			$args->rewrite['with_front'] = true;
 		$wp_rewrite->add_rewrite_tag("%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=");
-		$wp_rewrite->add_permastruct($post_type, "{$args->rewrite['slug']}/%$post_type%", $args->rewrite['with_front']);
+		$wp_rewrite->add_permastruct($post_type, "{$args->rewrite['slug']}/%$post_type%", $args->rewrite['with_front'], $args->permalink_epmask);
 	}
 
 	if ( $args->register_meta_box_cb )
Index: wp-includes/rewrite.php
===================================================================
--- wp-includes/rewrite.php	(revision 13689)
+++ wp-includes/rewrite.php	(working copy)
@@ -54,9 +54,9 @@
  * @param string $struct Permalink structure.
  * @param bool $with_front Prepend front base to permalink structure.
  */
-function add_permastruct( $name, $struct, $with_front = true ) {
+function add_permastruct( $name, $struct, $with_front = true, $ep_mask = EP_NONE ) {
 	global $wp_rewrite;
-	return $wp_rewrite->add_permastruct( $name, $struct, $with_front );
+	return $wp_rewrite->add_permastruct( $name, $struct, $with_front, $ep_mask );
 }
 
 /**
@@ -1083,7 +1083,7 @@
 			return false;
 
 		if ( isset($this->extra_permastructs[$name]) )
-			return $this->extra_permastructs[$name];
+			return $this->extra_permastructs[$name][0];
 
 		return false;
 	}
@@ -1359,6 +1359,8 @@
 				case '%day%':
 					$ep_mask_specific = EP_DAY;
 					break;
+				default:
+					$ep_mask_specific = EP_NONE;
 			}
 
 			//create query for /page/xx
@@ -1611,8 +1613,12 @@
 		$page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
 
 		// Extra permastructs
-		foreach ( $this->extra_permastructs as $permastruct )
-			$this->extra_rules_top = array_merge($this->extra_rules_top, $this->generate_rewrite_rules($permastruct, EP_NONE));
+		foreach ( $this->extra_permastructs as $permastruct ) {
+			if ( is_array($permastruct) )
+				$this->extra_rules_top = array_merge($this->extra_rules_top, $this->generate_rewrite_rules($permastruct[0], $permastruct[1]));
+			else
+				$this->extra_rules_top = array_merge($this->extra_rules_top, $this->generate_rewrite_rules($permastruct, EP_NONE));
+		}
 
 		// Put them together.
 		if ( $this->use_verbose_page_rules )
@@ -1906,10 +1912,10 @@
 	 * @param string $struct Permalink structure.
 	 * @param bool $with_front Prepend front base to permalink structure.
 	 */
-	function add_permastruct($name, $struct, $with_front = true) {
+	function add_permastruct($name, $struct, $with_front = true, $ep_mask = EP_NONE) {
 		if ( $with_front )
 			$struct = $this->front . $struct;
-		$this->extra_permastructs[$name] = $struct;
+		$this->extra_permastructs[$name] = array($struct, $ep_mask);
 	}
 
 	/**
