Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix replaces spaces and dots in links

  • Loading branch information...
commit be408079460deee089f1d9d2a10611e54179d3e7 1 parent cb13899
@Gemorroj authored
Showing with 27 additions and 1 deletion.
  1. +27 −1 bbcode.lib.php
View
28 bbcode.lib.php
@@ -1094,6 +1094,30 @@ function get_html($elems = null) {
return $result;
}
+
+ /**
+ * Аналог parse_str но без преобразования точек и пробелов в подчеркивания
+ *
+ * @todo не очень хорошая реализация
+ * @param string $str
+ * @return array
+ */
+ private function _parseStr ($str)
+ {
+ $dot = "xbbdot\txbbdot";
+ $space = "xbbspace\txbbspace";
+
+ parse_str(str_replace(array('.', ' '), array($dot, $space), $str), $query);
+
+ foreach ($query as $k => $v) {
+ unset($query[$k]);
+ $query[str_replace(array($dot, $space), array('.', ' '), $k)] = $v;
+ }
+
+ return $query;
+ }
+
+
/**
* Функция преобразует строку URL в соответствии с RFC 3986
* @param string $url
@@ -1121,7 +1145,9 @@ function checkUrl($url) {
$out .= str_replace('%2F', '/', rawurlencode($parse['path']));
}
if (isset($parse['query'])) {
- parse_str($parse['query'], $query);
+ $query = $this->_parseStr($parse['query']);
+ //parse_str($parse['query'], $query); //replace spaces and dots
+
// PHP 5.1.2
$out .= '?' . str_replace('+', '%20', rtrim(http_build_query($query, '', '&'), '='));
}
Please sign in to comment.
Something went wrong with that request. Please try again.