Index: trunk/extensions/SemanticForms/specials/SF_AddPage.php |
— | — | @@ -63,12 +63,19 @@ |
64 | 64 | if ('' != $page_name) { |
65 | 65 | // Append the namespace prefix to the page name, |
66 | 66 | // if a namespace was not already entered. |
67 | | - if (strpos($page_name,":") === false) |
| 67 | + if (strpos($page_name,":") === false && $target_namespace != '') |
68 | 68 | $page_name = $target_namespace . ":" . $page_name; |
69 | 69 | // find out whether this page already exists, |
70 | 70 | // and send user to the appropriate form |
71 | 71 | $page_title = Title::newFromText($page_name); |
72 | | - if ($page_title && $page_title->exists()) { |
| 72 | + if (! $page_title) { |
| 73 | + // if there was no page title, it's probably |
| 74 | + // an invalid page name, containing forbidden |
| 75 | + // characters |
| 76 | + $error_msg = wfMsg('sf_addpage_badtitle', $page_name); |
| 77 | + $wgOut->addHTML($error_msg); |
| 78 | + return; |
| 79 | + } elseif ($page_title->exists()) { |
73 | 80 | // it exists - see if page is a redirect; if |
74 | 81 | // it is, edit the target page instead |
75 | 82 | $article = new Article($page_title); |
— | — | @@ -98,25 +105,22 @@ |
99 | 106 | // 'AddData' only 'preload' and specific form |
100 | 107 | // fields - we can tell the latter because |
101 | 108 | // they show up as 'arrays' |
102 | | - $first_val_added = false; |
103 | 109 | foreach ($_REQUEST as $key => $val) { |
104 | 110 | if (is_array($val)) { |
105 | 111 | $template_name = $key; |
106 | 112 | foreach ($val as $field_name => $value) { |
107 | | - $redirect_url .= ($first_val_added) ? '&' : '?'; |
| 113 | + $redirect_url .= (strpos($redirect_url, "?") > -1) ? '&' : '?'; |
108 | 114 | $redirect_url .= $template_name . '[' . $field_name . ']=' . $value; |
109 | | - $first_val_added = true; |
110 | 115 | } |
111 | 116 | } elseif ($key == 'preload') { |
112 | | - $redirect_url .= ($first_val_added) ? '&' : '?'; |
| 117 | + $redirect_url .= (strpos($redirect_url, "?") > -1) ? '&' : '?'; |
113 | 118 | $redirect_url .= "$key=$val"; |
114 | | - $first_val_added = true; |
115 | 119 | } |
116 | 120 | } |
117 | 121 | } |
118 | 122 | |
119 | 123 | if ('' != $params) { |
120 | | - $redirect_url .= ($first_val_added) ? '&' : '?'; |
| 124 | + $redirect_url .= (strpos($redirect_url, "?") > -1) ? '&' : '?'; |
121 | 125 | $redirect_url .= $params; |
122 | 126 | } |
123 | 127 | |