? rewrite-clarification-2.patch
? rewrite-clarification.patch
? sites/default/files
? sites/default/private
? sites/default/settings.php
Index: modules/path/path.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/path/path.admin.inc,v
retrieving revision 1.42
diff -u -r1.42 path.admin.inc
--- modules/path/path.admin.inc 3 Mar 2010 19:46:25 -0000 1.42
+++ modules/path/path.admin.inc 29 Mar 2010 17:11:21 -0000
@@ -164,22 +164,27 @@
$source = &$form_state['values']['source'];
$source = drupal_get_normal_path($source);
$alias = $form_state['values']['alias'];
- $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0;
- // Language is only set if locale module is enabled, otherwise save for all languages.
- $language = isset($form_state['values']['language']) ? $form_state['values']['language'] : LANGUAGE_NONE;
-
- $has_alias = db_query("SELECT COUNT(alias) FROM {url_alias} WHERE pid <> :pid AND alias = :alias AND language = :language", array(
- ':pid' => $pid,
- ':alias' => $alias,
- ':language' => $language,
- ))
- ->fetchField();
-
- if ($has_alias) {
- form_set_error('alias', t('The alias %alias is already in use in this language.', array('%alias' => $alias)));
+ if (strpos($alias, '#') !== FALSE) {
+ form_set_error('alias', t('The # character is not valid in custom paths.'));
}
- if (!drupal_valid_path($source)) {
- form_set_error('source', t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $source)));
+ else {
+ $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0;
+ // Language is only set if locale module is enabled, otherwise save for all languages.
+ $language = isset($form_state['values']['language']) ? $form_state['values']['language'] : LANGUAGE_NONE;
+
+ $has_alias = db_query("SELECT COUNT(alias) FROM {url_alias} WHERE pid <> :pid AND alias = :alias AND language = :language", array(
+ ':pid' => $pid,
+ ':alias' => $alias,
+ ':language' => $language,
+ ))
+ ->fetchField();
+
+ if ($has_alias) {
+ form_set_error('alias', t('The alias %alias is already in use in this language.', array('%alias' => $alias)));
+ }
+ if (!drupal_valid_path($source)) {
+ form_set_error('source', t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $source)));
+ }
}
}
Index: modules/path/path.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/path/path.module,v
retrieving revision 1.183
diff -u -r1.183 path.module
--- modules/path/path.module 13 Feb 2010 21:41:58 -0000 1.183
+++ modules/path/path.module 29 Mar 2010 17:11:22 -0000
@@ -165,17 +165,22 @@
$path = $form_state['values']['path'];
- // Ensure that the submitted alias does not exist yet.
- $query = db_select('url_alias')
- ->condition('alias', $path['alias'])
- ->condition('language', $path['language']);
- if (!empty($path['source'])) {
- $query->condition('source', $path['source'], '<>');
- }
- $query->addExpression('1');
- $query->range(0, 1);
- if ($query->execute()->fetchField()) {
- form_set_error('alias', t('The alias is already in use.'));
+ if (strpos($path['alias'], '#') !== FALSE) {
+ form_set_error('alias', t('The # character is not valid in custom paths.'));
+ }
+ else {
+ // Ensure that the submitted alias does not exist yet.
+ $query = db_select('url_alias')
+ ->condition('alias', $path['alias'])
+ ->condition('language', $path['language']);
+ if (!empty($path['source'])) {
+ $query->condition('source', $path['source'], '<>');
+ }
+ $query->addExpression('1');
+ $query->range(0, 1);
+ if ($query->execute()->fetchField()) {
+ form_set_error('alias', t('The alias is already in use.'));
+ }
}
}
}
Index: modules/path/path.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/path/path.test,v
retrieving revision 1.35
diff -u -r1.35 path.test
--- modules/path/path.test 26 Mar 2010 12:37:30 -0000 1.35
+++ modules/path/path.test 29 Mar 2010 17:11:22 -0000
@@ -70,7 +70,7 @@
$pid = $this->getPID($edit['alias']);
$previous = $edit['alias'];
- $edit['alias'] = "- ._~!$'\"()*@[]?&+%#,;=:" . // "Special" ASCII characters.
+ $edit['alias'] = "- ._~!$'\"()*@[]?&+%,;=:" . // "Special" ASCII characters.
"%23%25%26%2B%2F%3F" . // Characters that look like a percent-escaped string.
"éøïвβ中國書۞"; // Characters from various non-ASCII alphabets.
$this->drupalPost('admin/config/search/path/edit/' . $pid, $edit, t('Save'));
@@ -86,12 +86,21 @@
$this->assertNoText($node1->title, 'Previous alias no longer works.');
$this->assertResponse(404);
+ // Attempt to set the path to one containing a # character.
+ $previous = $edit['alias'];
+ $edit['alias'] = 'foo#bar';
+ $this->drupalPost('admin/config/search/path/edit/' . $pid, $edit, t('Save'));
+
+ // Confirm that wasn't allowed.
+ $this->assertRaw(t('The # character is not valid in custom paths.'), 'Attempt to create a path with the # character was rejected.');
+
// Create second test node.
$node2 = $this->drupalCreateNode();
// Set alias to second test node.
$edit['source'] = 'node/' . $node2->nid;
- // leave $edit['alias'] the same
+ // Reset $edit['alias'] to the previous working value.
+ $edit['alias'] = $previous;
$this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
// Confirm no duplicate was created.
@@ -126,7 +135,7 @@
// Change alias to one containing "exotic" characters.
$previous = $edit['path[alias]'];
- $edit['path[alias]'] = "- ._~!$'\"()*@[]?&+%#,;=:" . // "Special" ASCII characters.
+ $edit['path[alias]'] = "- ._~!$'\"()*@[]?&+%,;=:" . // "Special" ASCII characters.
"%23%25%26%2B%2F%3F" . // Characters that look like a percent-escaped string.
"éøïвβ中國書۞"; // Characters from various non-ASCII alphabets.
$this->drupalPost('node/' . $node1->nid . '/edit', $edit, t('Save'));
@@ -141,11 +150,20 @@
$this->assertNoText($node1->title, 'Previous alias no longer works.');
$this->assertResponse(404);
+ // Attempt to set the path to one containing a # character.
+ $previous = $edit['path[alias]'];
+ $edit['path[alias]'] = 'foo#bar';
+ $this->drupalPost('node/' . $node1->nid . '/edit', $edit, t('Save'));
+
+ // Confirm that wasn't allowed.
+ $this->assertRaw(t('The # character is not valid in custom paths.'), 'Attempt to create a path with the # character was rejected.');
+
// Create second test node.
$node2 = $this->drupalCreateNode();
// Set alias to second test node.
- // Leave $edit['path[alias]'] the same.
+ // Reset $edit['path[alias]'] to the previous working value.
+ $edit['path[alias]'] = $previous;
$this->drupalPost('node/' . $node2->nid . '/edit', $edit, t('Save'));
// Confirm that the alias didn't make a duplicate.