mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2025-01-31 21:11:39 +01:00
Fix #1211 - strip control characters from input - thx SirEllert / xylographe :)
This commit is contained in:
parent
020e95c5b2
commit
aae3152746
@ -200,7 +200,7 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
|
||||
public bool Add(string name)
|
||||
{
|
||||
name = name.Trim();
|
||||
name = name.Trim().RemoveControlCharacters();
|
||||
if (name.Length > 1 && name.ContainsLetter())
|
||||
{
|
||||
if (name.Contains(' '))
|
||||
|
@ -79,7 +79,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
NewName = textBoxAddName.Text.Trim();
|
||||
NewName = textBoxAddName.Text.Trim().RemoveControlCharacters();
|
||||
string languageName = null;
|
||||
_language = Configuration.Settings.Language.Main;
|
||||
|
||||
|
@ -22,8 +22,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void buttonOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
string key = textBoxOcrFixKey.Text.Trim();
|
||||
string value = textBoxOcrFixValue.Text.Trim();
|
||||
string key = textBoxOcrFixKey.Text.Trim().RemoveControlCharacters();
|
||||
string value = textBoxOcrFixValue.Text.Trim().RemoveControlCharacters();
|
||||
if (key.Length == 0 || value.Length == 0 || key == value)
|
||||
return;
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void buttonOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
NewWord = textBoxAddName.Text.Trim().ToLower();
|
||||
NewWord = textBoxAddName.Text.Trim().ToLower().RemoveControlCharacters();
|
||||
if (NewWord.Length == 0)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
|
@ -360,7 +360,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (listViewReplaceList.SelectedItems.Count != 1)
|
||||
return;
|
||||
|
||||
if (textBoxFind.Text.Length > 0)
|
||||
string findText = textBoxFind.Text.RemoveControlCharacters();
|
||||
textBoxFind.Text = findText;
|
||||
|
||||
string replaceText = textBoxReplace.Text.RemoveControlCharacters();
|
||||
textBoxReplace.Text = replaceText;
|
||||
|
||||
if (findText.Length > 0)
|
||||
{
|
||||
string searchType = SearchTypeNormal;
|
||||
if (radioButtonCaseSensitive.Checked)
|
||||
@ -370,7 +376,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
else if (radioButtonRegEx.Checked)
|
||||
{
|
||||
searchType = SearchTypeRegularExpression;
|
||||
if (!Utilities.IsValidRegex(textBoxFind.Text))
|
||||
if (!Utilities.IsValidRegex(findText))
|
||||
{
|
||||
MessageBox.Show(Configuration.Settings.Language.General.RegularExpressionIsNotValid);
|
||||
textBoxFind.Select();
|
||||
@ -379,8 +385,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
var item = listViewReplaceList.SelectedItems[0];
|
||||
item.SubItems[1].Text = textBoxFind.Text;
|
||||
item.SubItems[2].Text = textBoxReplace.Text;
|
||||
item.SubItems[1].Text = findText;
|
||||
item.SubItems[2].Text = replaceText;
|
||||
item.SubItems[3].Text = EnglishSearchTypeToLocal(searchType);
|
||||
|
||||
GeneratePreview();
|
||||
|
@ -1797,7 +1797,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private void ButtonAddNamesEtcClick(object sender, EventArgs e)
|
||||
{
|
||||
string language = GetCurrentWordListLanguage();
|
||||
string text = textBoxNameEtc.Text.Trim();
|
||||
string text = textBoxNameEtc.Text.Trim().RemoveControlCharacters();
|
||||
if (!string.IsNullOrEmpty(language) && text.Length > 1 && !_wordListNamesEtc.Contains(text))
|
||||
{
|
||||
var namesList = new NamesList(Configuration.DictionariesFolder, language, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
@ -1897,7 +1897,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private void ButtonAddUserWordClick(object sender, EventArgs e)
|
||||
{
|
||||
string language = GetCurrentWordListLanguage();
|
||||
string text = textBoxUserWord.Text.Trim().ToLower();
|
||||
string text = textBoxUserWord.Text.Trim().ToLower().RemoveControlCharacters();
|
||||
if (!string.IsNullOrEmpty(language) && text.Length > 0 && !_userWordList.Contains(text))
|
||||
{
|
||||
Utilities.AddToUserDictionary(text, language);
|
||||
@ -2006,8 +2006,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void ButtonAddOcrFixClick(object sender, EventArgs e)
|
||||
{
|
||||
string key = textBoxOcrFixKey.Text.Trim();
|
||||
string value = textBoxOcrFixValue.Text.Trim();
|
||||
string key = textBoxOcrFixKey.Text.Trim().RemoveControlCharacters();
|
||||
string value = textBoxOcrFixValue.Text.Trim().RemoveControlCharacters();
|
||||
if (key.Length == 0 || value.Length == 0 || key == value || Utilities.IsInteger(key))
|
||||
return;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user