Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions csharp/DiffMatchPatch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Diff Match and Patch
* Copyright 2018 The diff-match-patch Authors.
* https://github.com/google/diff-match-patch
Expand All @@ -19,11 +19,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;

namespace DiffMatchPatch {

internal static class CompatibilityExtensions {
// JScript splice function
public static List<T> Splice<T>(this List<T> input, int start, int count,
Expand Down Expand Up @@ -1474,7 +1475,7 @@ public List<Diff> diff_fromDelta(string text1, string delta) {
// decode would change all "+" to " "
param = param.Replace("+", "%2b");

param = HttpUtility.UrlDecode(param);
param = WebUtility.UrlDecode(param);
//} catch (UnsupportedEncodingException e) {
// // Not likely on modern system.
// throw new Error("This system does not support UTF-8.", e);
Expand Down Expand Up @@ -2249,7 +2250,7 @@ Regex patchHeader
}
line = text[textPointer].Substring(1);
line = line.Replace("+", "%2b");
line = HttpUtility.UrlDecode(line);
line = WebUtility.UrlDecode(line);
if (sign == '-') {
// Deletion.
patch.diffs.Add(new Diff(Operation.DELETE, line));
Expand Down Expand Up @@ -2282,7 +2283,7 @@ Regex patchHeader
*/
public static string encodeURI(string str) {
// C# is overzealous in the replacements. Walk back on a few.
return new StringBuilder(HttpUtility.UrlEncode(str))
return new StringBuilder(WebUtility.UrlEncode(str))
.Replace('+', ' ').Replace("%20", " ").Replace("%21", "!")
.Replace("%2a", "*").Replace("%27", "'").Replace("%28", "(")
.Replace("%29", ")").Replace("%3b", ";").Replace("%2f", "/")
Expand Down