Commit Graph
47 Commits
Author SHA1 Message Date
Kenneth Skovhede 704485176a Clarified the Path parameter 2025-02-24 13:56:28 +01:00
Kenneth Skovhede 80d60c0982 Fix Uri ToString()
Fixed a case where an extra leading slash would be removed when converting a parsed Uri back to a string.
2025-02-19 22:23:53 +01:00
Kenneth SkovhedeandGitHub 9464caf622 Feature/update license 2025 (#5851)
* Fixed some minor whitespace issues

* Updated all copyright to 2025
2025-01-07 09:40:39 +01:00
Kenneth Skovhede 8250a5befa Refactored SecretProviderHelper to replace in Uri instances instead of raw string.
This fixes some issues with URL encoding/decoding.
Due to the legacy class `Duplicati.Library.Utility.Uri` there are two replacements done.
2024-11-04 15:57:56 +01:00
Kenneth SkovhedeandGitHub ffacd37e44 Merge branch 'master' into fix-ipv6-uri 2024-03-04 13:41:10 +01:00
Kenneth Skovhede 40dd3c6816 Updated all license mentions to MIT 2024-02-28 15:45:30 +01:00
Jojo-1000 a45ce610df Fix URI parsing for IPv6 addresses and add tests.
Closes #5057
2023-11-10 13:53:10 +01:00
Kenneth Hsu f28550f4b5 Use overload instead of optional parameters.
From Codacy:

The overloading mechanism should be used in place of optional parameters for several reasons:

* Optional parameter values are baked into the method call site code,
  thus, if a default value has been changed, all referencing assemblies
  need to be rebuilt, otherwise the original values will be used.
* The Common Language Specification (CLS) allows compilers to ignore
  default parameter values, and thus require the caller to explicitly
  specify the values. For example, if you want to consume a method with
  default argument from another .NET compatible language (for instance
  C++/CLI), you will have to provide all arguments. When using method
  overloads, you could achieve similar behavior as default arguments.
* Optional parameters prevent muddying the definition of the function
  contract. Here is a simple example: if there are two optional
  parameters, when one is defined, is the second one still optional or
  mandatory?
2020-08-24 07:51:57 -07:00
Kenneth Hsu d4d7874aaf Avoid decoding URL parameters when removing passwords.
In revision c41f2c6a60 ("moved all sanitization logic into backup class
and moved from regex to using internal Uri library"), we cleaned up the
removal of passwords from an exported backup configuration.  However,
the use of Uri.QueryParameters resulted in exporting decoded parameter
values, which violated some assumptions made by the decode_uri function
in AppUtils.js.  This caused usernames in the JSON to contain '@'
instead of '%40', which led to incorrect decomposition of the target URL
into its components in the UI.

This concerns issue #3619.
2020-08-24 07:41:00 -07:00
Kenneth Hsu 83ac03843d Fix spelling errors in comments.
In doing so, we also normalized some line endings.
2019-12-14 09:52:55 -08:00
Kenneth Hsu 2aa76881a5 Mark fields that don't need to be reassigned as readonly.
This makes it explicit at compile-time that these fields should not be
reassigned outside the constructor.
2019-10-19 13:59:22 -07:00
Kenneth Hsu 9e465c602d Fix invalid regex pattern.
This was introduced as part of revision b8199ad1c4 ("Fixed handling of
multi-byte characters in both HttpServer and Duplicati") to resolve
issues #1063 and #1085.  However, the regex pattern was invalid.  This
reverts the pattern to the previous value, which seems more appropriate
since most non-standard encodings are of the form %uxxxx where xxxx is a
4 byte hex string representing a UTF-16 code.

This fixes issue #3737.
2019-09-28 10:05:34 -07:00
verhoek 41234a314d Introduced UrlPath wrapper for stringbuilder to ease concatenation of multiple paths.
Started cleaning googlecloud services API.
2018-05-18 22:55:09 +02:00
verhoek be79384966 Removed duplicate ? when building urls with query parameters. 2018-05-15 21:50:14 +02:00
verhoek bbf489c86f Corrected appending paths to urls. 2018-05-14 22:53:13 +02:00
verhoek 6dd64a553d Fixed code quality issues. 2018-05-14 21:01:18 +02:00
verhoek 44b5b00276 Renamed some googledriveapi var names. Modified ListFolder to be more readable. 2018-05-11 19:57:09 +02:00
verhoek 78a46c3a5c Renamed misspelled class urluttility to urlutility and newly added urlutility to uriutility. 2018-05-11 19:09:14 +02:00
verhoek d303db30d6 Replacing magic strings in google drive rest calls by query key value pairs. 2018-05-11 18:23:16 +02:00
Kenneth SkovhedeandGitHub 96cd4dd725 Merge pull request #3087 from warwickmm/use_nameof_operator
Use nameof operator when constructing ArgumentNullException
2018-03-08 11:14:49 +01:00
Kenneth Hsu ec7aa3113b Fix namespace in code references in XML documentation. 2018-03-07 18:34:26 -08:00
Kenneth Hsu 1f8b542604 Use nameof operator when constructing ArgumentNullException.
This will make rename refactorings easier in the future.
2018-03-07 17:53:08 -08:00
Kenneth Hsu 8810e0130d Make string comparisons use ordinal (binary) sort rules.
These string comparisons should not be culture-aware.
2017-11-26 11:19:54 -08:00
Kenneth Hsu b84e7bd34d Avoid hard-coded parameter names.
This makes it easier to rename the parameter in the future as we don't
have to search for the parameter name within strings.
2017-09-25 19:54:54 -07:00
Tyler Gill 83a1dcfb64 Replace all instances of InvariantCultureIgnoreCase with OrdinalIgnoreCase in string comparisons.
InvariantCulture is useful when comparing / sorting human language strings in a culturely correct way. It handles things like accented letters in a way that makes sense to humans (e.g., 'a' should be sorted next to 'á', rather than after 'z').
Ordinal looks just at the raw code points of the characters. As such, it is recommended for use in cases when comparing system strings (file paths, command line parameters, config settings, etc.). Since it doesn't need to use the culture specific sorting rules, this method can often be faster.

For more information, see https://stackoverflow.com/questions/492799/difference-between-invariantculture-and-ordinal-string-comparison (and other related questions)
2017-09-18 23:55:08 -06:00
Kenneth Skovhede 66aaaab0a8 Fixed an issue with the URL parser being a little too flexible, which breaks if the URL has the port component.
This change means that URL's in the form `scheme://username:password@server` can no longer have any of the characters `:?/` in the username or password component without encoding.
2017-03-07 11:05:49 +01:00
Vaporizer8andGitHub 228ade0209 Handle paths with leading /
Paths with a leading / can cause issues with some WebDAV servers (IIS) as this results in https://example.com//foo/bar/
2016-07-12 21:33:28 +02:00
Kenneth Skovhede 3149064cde Merge branch 'no_more_resx' 2015-01-20 21:45:54 +01:00
Kenneth Skovhede 8d13e698eb Updated copyright notices 2015-01-20 21:44:52 +01:00
Kenneth Skovhede 16c791f0b5 Removed all resx files, now using Duplicati.Library.Localization exclusively 2015-01-20 21:07:24 +01:00
Kenneth Skovhede 89cedb89ca Fixed handling file://c:\test with the new parser 2014-09-02 18:05:07 +02:00
Kenneth Skovhede 66cb9df64d Fixed #1090
Handling URI with no hostname
2014-08-26 12:52:53 +02:00
Kenneth Skovhede 63987d2369 Fixed an escape char that did not work well with Windows 2014-08-16 14:19:32 +02:00
Kenneth Skovhede b8199ad1c4 Fixed handling of multi-byte characters in both HttpServer and Duplicati.
This fixes issue #1085 and issue #1063.
2014-08-13 23:42:26 +02:00
Kenneth Skovhede 00e6554842 Allowed detection of URI with no hostname component 2014-07-25 15:48:10 +02:00
Kenneth Skovhede d0ea1de01a Added UrlPathEncode i utility 2014-06-09 09:13:17 +02:00
Kenneth Skovhede 5f5c309cec Fixed parsing windows paths with file:// prefix 2014-03-20 15:07:47 +01:00
Kenneth Skovhede 4dafb85ec9 Exposed the url encode/decode functions 2014-03-12 01:42:16 +01:00
Kenneth Skovhede f82f2b3b0e Updated URI regexp to be even more flexible 2014-02-28 14:02:51 +01:00
Kenneth Skovhede add5534c50 Don't depend on System.Web because it is broken on Mono
Update issue #940
Status: Fixed

I took another approach and now manually parse and encode these strings.
This is done to avoid using System.Uri.EscapeUriString because it has some subtle issues:
http://blogs.msdn.com/b/yangxind/archive/2006/11/09/don-t-use-net-system-uri-unescapedatastring-in-url-decoding.aspx
2014-02-10 14:35:02 +01:00
Kenneth Skovhede c3ae36b4cd Fixed parsing urls with no path information 2013-05-20 14:05:28 +02:00
Kenneth Skovhede c596434cab Removed unused options and dropped the fh- prefix for forest hash options 2013-05-08 19:57:13 +02:00
Kenneth Skovhede d3f4058057 Fixed various minor issues with backends 2013-05-06 20:36:26 +02:00
Kenneth Skovhede 07adaa53c9 Added url encode/decode for the username and password to allow all kinds of username/password setups 2013-05-06 09:10:41 +02:00
Kenneth Skovhede 68bf7109f7 Bugfix to the Uri parser 2013-05-06 09:00:29 +02:00
Kenneth Skovhede e5b3f0ea93 Rewrote all backends to use the new Uri parser.
Updated the regex to be a little more forgiving.
Does not handle paths with @, like "ftp://server/@folder"
2013-05-05 23:46:00 +02:00
Kenneth Skovhede 86b52d364d Added a custom URL parser 2013-05-05 21:18:00 +02:00