Browse Source

normalize smart quotes in search queries (#605)

pull/606/head
Jason Dove 4 years ago committed by GitHub
parent
commit
90d6a59d3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      CHANGELOG.md
  2. 12
      ErsatzTV/Extensions/StringExtensions.cs

3
CHANGELOG.md

@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Fixed
- Normalize smart quotes in search queries as they are unsupported by the search library
### Added
- Include `Series` category tag for all episodes in XMLTV
- Include movie, episode (show) genres as `category` tags in XMLTV

12
ErsatzTV/Extensions/StringExtensions.cs

@ -43,7 +43,9 @@ namespace ErsatzTV.Extensions @@ -43,7 +43,9 @@ namespace ErsatzTV.Extensions
public static EncodedQueryResult EncodeQuery(this string query)
{
string encoded = Uri.EscapeDataString(query);
string normalizedQuery = Normalize(query);
string encoded = Uri.EscapeDataString(normalizedQuery);
// TODO: remove this on dotnet 6
// see https://github.com/dotnet/aspnetcore/pull/26769
@ -54,5 +56,13 @@ namespace ErsatzTV.Extensions @@ -54,5 +56,13 @@ namespace ErsatzTV.Extensions
}
public record EncodedQueryResult(string Key, string Value);
private static string Normalize(string s)
{
// normalize single and double quotes
return !string.IsNullOrEmpty(s)
? s.Replace('\u2018', '\'').Replace('\u2019', '\'').Replace('\u201c', '\"').Replace('\u201d', '\"')
: s;
}
}
}

Loading…
Cancel
Save