Remove duplicate GET parameters and clean &amp; and duplicate &.

@param string $sUrl       url to process.
@param string $sConnector GET elements connector.

@return string
7166
public function cleanUrlParams($sUrl, $sConnector = '&amp;')
    {
        $aUrlParts = explode('?', $sUrl);

        // check for params part
        if (!is_array($aUrlParts) || count($aUrlParts) != 2) {
            return $sUrl;
        }

        $sUrl = $aUrlParts[0];
        $sUrlParams = $aUrlParts[1];

        /** @var \OxidEsales\Eshop\Core\StrRegular $oStrUtils */
        $oStrUtils = getStr();
        $sUrlParams = $oStrUtils->preg_replace(
            ['@(\&(amp;){1,})@ix', '@\&{1,}@', '@\?&@x'],
            ['&', '&', '?'],
            $sUrlParams
        );

        // remove duplicate entries
        parse_str($sUrlParams, $aUrlParams);
        $sUrl .= '?' . http_build_query($aUrlParams, '', $sConnector);

        // replace brackets
        $sUrl = str_replace(
            ['%5B', '%5D'],
            ['[', ']'],
            $sUrl
        );

        return $sUrl;
    }
1266630
public static ScmConnector create(String scmType, String url, String privateKey, String username, String password, String branch, String tag) {
        ScmConnector scmConnector = null;
        if (StringUtils.isNotBlank(scmType)) {
            ScmType type = ScmType.getValue(scmType);
            if (type == null) {
                throw new IllegalArgumentException("Invalid scm type, please select git / svn / mercurial");
            }

            if (StringUtils.isBlank(url)) {
                throw new IllegalArgumentException("No scm link provided");
            }

            switch (type) {
                case GIT:
                    scmConnector = new GitConnector(privateKey, username, password, url, branch, tag);
                    break;
                case SVN:
                    scmConnector = new SvnConnector(username, password, url, branch, tag);
                    break;
                case MERCURIAL:
                    scmConnector = new MercurialConnector(username, password, url, branch, tag);
                    break;
                default: throw new IllegalArgumentException("Unsupported scm type");
            }
        }
        return scmConnector;
    }
1209654
protected function _fetchCurVersionInfo($sUrl)
    {
        $aParams = ["myversion" => \OxidEsales\Eshop\Core\Registry::getConfig()->getVersion()];
        $oLang = \OxidEsales\Eshop\Core\Registry::getLang();
        $iLang = $oLang->getTplLanguage();
        $sLang = $oLang->getLanguageAbbr($iLang);

        $oCurl = oxNew(\OxidEsales\Eshop\Core\Curl::class);
        $oCurl->setMethod("POST");
        $oCurl->setUrl($sUrl . "/" . $sLang);
        $oCurl->setParameters($aParams);
        $sOutput = $oCurl->execute();

        $sOutput = strip_tags($sOutput, "<br>, <b>");
        $aResult = explode("<br>", $sOutput);
        if (strstr($aResult[5], "update")) {
            $sUpdateLink = \OxidEsales\Eshop\Core\Registry::getLang()->translateString("VERSION_UPDATE_LINK");
            $aResult[5] = "<a id='linkToUpdate' href='$sUpdateLink' target='_blank'>" . $aResult[5] . "</a>";
        }

        return implode("<br>", $aResult);
    }
230463
protected function recv(bool $defer = false, bool $release = true)
    {
        if ($this->connection instanceof ConnectionInterface) {
            try {
                $result = $this->connection->receive();
            } catch (\Throwable $throwable) {
                throw $throwable;
            } finally {
                $this->release($release);
            }

            return $result;
        }

        try {
            $result = $this->connection->recv();
        } catch (\Throwable $throwable) {
            throw $throwable;
        } finally {
            if ($defer) {
                $this->connection->setDefer(false);
            }
        }

        return $result;
    }
220193
protected function GetErrorURL($sStepName = '')
    {
        if (empty($sStepName)) {
            $sStepName = 'shipping';
        }
        $sURL = false;
        $oShippingStep = TdbShopOrderStep::GetStep($sStepName);
        /** @var $oShippingStep TdbShopOrderStep */
        if (!is_null($oShippingStep)) {
            $sURL = $oShippingStep->GetStepURL(true, true);
            if ('/' == substr($sURL, -1)) {
                $sURL = substr($sURL, 0, -1);
            }
        }

        return $sURL;
    }
984084
private String detokenizeURLs(String line) {
    final Matcher linkMatcher = wrongLink.matcher(line);
    final StringBuffer sb = new StringBuffer();
    while (linkMatcher.find()) {
      linkMatcher.appendReplacement(sb,
          linkMatcher.group().replaceAll("\\s", ""));
    }
    linkMatcher.appendTail(sb);
    line = sb.toString();
    return line;
  }
733792
protected function receive($multiline = false)
    {
        $result = @fgets($this->socket);
        $status = $result = trim($result);
        $message = '';

        if (strpos($result, ' ')) {
            list($status, $message) = explode(' ', $result, 2);
        }

        if ($status != '+OK') {
            return false;
        }

        if ($multiline) {
            $message = '';
            $line = fgets($this->socket);
            while ($line && rtrim($line, "\r\n") != '.') {
                if ($line[0] == '.') {
                    $line = substr($line, 1);
                }
                $this->debug('Receiving: '.$line);
                $message .= $line;
                $line = fgets($this->socket);
            };
        }

        return $message;
    }
472903
function(sMethod, sUrl) {
			var sUrlResourcePart = new URI(sUrl).resource();
			sUrlResourcePart = this.replaceEntriesUrlByRegex(sUrlResourcePart);
			return sMethod + sUrlResourcePart;
		}
1030602
protected function _trimUrl($sUrl, $iLang = null)
    {
        $myConfig = \OxidEsales\Eshop\Core\Registry::getConfig();
        $oStr = getStr();
        $sUrl = str_replace([$myConfig->getShopUrl($iLang, false), $myConfig->getSslShopUrl($iLang)], '', $sUrl);
        $sUrl = $oStr->preg_replace('/(\?|&(amp;)?)(force_)?(admin_)?sid=[a-z0-9\.]+&?(amp;)?/i', '\1', $sUrl);
        $sUrl = $oStr->preg_replace('/(\?|&(amp;)?)shp=[0-9]+&?(amp;)?/i', '\1', $sUrl);
        $sUrl = $oStr->preg_replace('/(\?|&(amp;)?)lang=[0-9]+&?(amp;)?/i', '\1', $sUrl);
        $sUrl = $oStr->preg_replace('/(\?|&(amp;)?)cur=[0-9]+&?(amp;)?/i', '\1', $sUrl);
        $sUrl = $oStr->preg_replace('/(\?|&(amp;)?)stoken=[a-z0-9]+&?(amp;)?/i', '\1', $sUrl);
        $sUrl = $oStr->preg_replace('/(\?|&(amp;)?)&(amp;)?/i', '\1', $sUrl);
        $sUrl = $oStr->preg_replace('/(\?|&(amp;)?)+$/i', '', $sUrl);
        $sUrl = trim($sUrl);

        // max length <= $this->_iMaxUrlLength
        $iLength = $this->_getMaxUrlLength();
        if ($oStr->strlen($sUrl) > $iLength) {
            $sUrl = $oStr->substr($sUrl, 0, $iLength);
        }

        return $sUrl;
    }
373392
public function getValue($sSelector)
    {
        $element = $this->getElementLazy($sSelector);
        $mValue = $this->_getValue($element->getXpath());

        try {
            $sType = $element->getAttribute('type');
        } catch (InvalidArgumentException $e) {
            sleep(1);
            $sType = $element->getAttribute('type');
        }
        if ($sType == 'checkbox') {
            $mValue = $mValue ? 'on' : 'off';
        }

        return trim($mValue);
    }
866682
function(sUrl) {
			for (var i = 0; i < this.aEntriesUrlReplace.length; i++) {
				var oEntry = this.aEntriesUrlReplace[i];
				if (oEntry.regex instanceof RegExp && oEntry.value !== undefined) {
					sUrl = sUrl.replace(oEntry.regex, oEntry.value);
				} else {
					this.oLog.warning(sModuleName + " - Invalid regular expression for url replace.");
				}
			}
			return sUrl;
		}
89846
protected function _cleanupUrl($sUrl)
    {
        // replacing &amp; to & or removing double &&
        while ((stripos($sUrl, '&amp;') !== false) || (stripos($sUrl, '&&') !== false)) {
            $sUrl = str_replace('&amp;', '&', $sUrl);
            $sUrl = str_replace('&&', '&', $sUrl);
        }

        // converting & to &amp;
        return str_replace('&', '&amp;', $sUrl);
    }
566761
public function getSlice($offset, $length)
    {
        $query = clone $this->query;
        $query->offset = $offset;
        $query->limit = $length;
        $query->performCount = false;

        $searchResult = $this->searchService->findLocations($query, $this->languageFilter);

        // Set count for further use if returned by search engine despite !performCount (Solr, ES)
        if (!isset($this->nbResults) && isset($searchResult->totalCount)) {
            $this->nbResults = $searchResult->totalCount;
        }

        return $searchResult->searchHits;
    }
1014395
public static boolean isCSSURLRequiringQuotes (@Nonnull final String sURL)
  {
    ValueEnforcer.notNull (sURL, "URL");

    for (final char c : sURL.toCharArray ())
      if (!isValidCSSURLChar (c))
        return true;
    return false;
  }
573301
@Nullable
  public String getWithoutProtocol (@Nullable final String sURL)
  {
    final IURLProtocol aProtocol = getProtocol (sURL);
    return aProtocol == null ? sURL : sURL.substring (aProtocol.getProtocol ().length ());
  }
534797
public function getJsonSmd( $clientUrl )
	{
		$services = array();
		$transport = array( 'envelope' => 'JSON-RPC-2.0', 'transport' => 'POST' );

		foreach( $this->_getControllers() as $controller )
		{
			foreach( $controller->getServiceDescription() as $method => $entry ){
				$services[$method] = $entry + $transport;
			}
		}

		$smd = array(
			'transport' => 'POST',
			'envelope' => 'JSON-RPC-2.0',
			'contentType' => 'application/json',
			'SMDVersion' => '2.0',
			'target' => $clientUrl,
			'services' => $services,
		);

		if( ( $json = json_encode( $smd ) ) === null ) {
			throw new Exception( 'Unable to encode service mapping description to JSON' );
		}

		return $json;
	}
422095
public function isCurrentShopHost($sUrl)
    {
        $blCurrent = false;
        $sUrlHost = @parse_url($sUrl, PHP_URL_HOST);
        // checks if it is relative url.
        if (is_null($sUrlHost)) {
            $blCurrent = true;
        } else {
            $aHosts = $this->_getHosts();

            foreach ($aHosts as $sHost) {
                if ($sHost === $sUrlHost) {
                    $blCurrent = true;
                    break;
                }
            }
        }

        return $blCurrent;
    }