{"record":{"id":"eb5bee446ac8bc02","repo":"BCUninstaller/Bulk-Crap-Uninstaller","slug":"value-cannot-contain-newlines","errorCode":null,"errorMessage":"Value cannot contain newlines","messagePattern":"Value cannot contain newlines","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"source/UninstallTools/Lists/Filter.cs","lineNumber":30,"sourceCode":"\r\nnamespace UninstallTools.Lists\r\n{\r\n    public class Filter : ITestEntry\r\n    {\r\n        public Filter()\r\n        {\r\n        }\r\n\r\n        public Filter(string name, string filterText)\r\n        {\r\n            if (!string.IsNullOrEmpty(name))\r\n                Name = name;\r\n\r\n            if (string.IsNullOrEmpty(filterText))\r\n                throw new ArgumentException(Localisation.UninstallListItem_ValueEmpty, nameof(filterText));\r\n\r\n            if (filterText.ContainsAny(StringTools.NewLineChars, StringComparison.Ordinal))\r\n                throw new ArgumentException(Localisation.UninstallListItem_NewLineInValue, nameof(filterText));\r\n\r\n            ComparisonEntries.Add(new FilterCondition { FilterText = filterText });\r\n        }\r\n\r\n        public Filter(string name, bool exclude, params FilterCondition[] conditions)\r\n        {\r\n            if (!string.IsNullOrEmpty(name))\r\n                Name = name;\r\n            Exclude = exclude;\r\n            ComparisonEntries.AddRange(conditions);\r\n        }\r\n\r\n        public string Name { get; set; } = Localisation.UninstallListEditor_NewFilter;\r\n\r\n        /// <summary>\r\n        /// Exclude items matched by this entry from results of the parent uninstall list\r\n        /// </summary>\r\n        public bool Exclude { get; set; }\r","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/BCUninstaller/Bulk-Crap-Uninstaller/blob/608321de98e92297377b1eb69029af55c25504a1/source/UninstallTools/Lists/Filter.cs#L12-L48","documentation":"The same Filter(string name, string filterText) constructor checks filterText.ContainsAny(StringTools.NewLineChars) and throws ArgumentException (param 'filterText') if it contains any newline character. Filters are single-line match expressions; a newline would create an ambiguous multi-line rule and break serialisation round-trips, so it is rejected explicitly after the empty-check.","triggerScenarios":"Passing filterText that contains '\\r', '\\n', or '\\r\\n' to 'new Filter(name, filterText)'. Happens when copying a multi-line selection from a textbox, pasting from a clipboard that includes a trailing newline, or deserialising XML where the element text was written with formatting indentation.","commonSituations":"User pastes a filter copied from a chat/log that spans two lines; XML serialiser preserves whitespace/newlines in element content; programmatic filter built from Environment.NewLine-joined tokens.","solutions":["Strip newline characters before constructing the Filter: filterText = filterText.Replace(\"\\r\", \" \").Replace(\"\\n\", \" \") (or split into multiple Filter objects).","In the UI, use a single-line TextBox (Multiline=false) for filter input.","Normalise loaded XML text with XmlReaderSettings.IgnoreWhitespace and trim before passing to the constructor."],"exampleFix":"// before\nvar filter = new Filter(name, rawFilterText);\n\n// after\nvar cleaned = string.Join(' ', rawFilterText.Split(StringTools.NewLineChars,\n    StringSplitOptions.RemoveEmptyEntries));\nvar filter = new Filter(name, cleaned);","handlingStrategy":"validation","validationCode":"var cleaned = string.Join(' ',\n    (filterText ?? string.Empty).Split(StringTools.NewLineChars,\n        StringSplitOptions.RemoveEmptyEntries));\nif (string.IsNullOrWhiteSpace(cleaned))\n    throw new InvalidOperationException(\"Filter text is required.\");\nvar filter = new Filter(name, cleaned);","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Use single-line text inputs in the UI for filter text.","Strip newlines from pasted clipboard content before constructing a Filter.","Set XmlReaderSettings.IgnoreWhitespace when loading lists from XML."],"tags":["validation","argument-exception","filters","uninstall-list","string-normalisation"],"backgroundTag":null,"analyzedSha":"608321de98e92297377b1eb69029af55c25504a1","analyzedAt":"2026-08-13T12:17:35.389Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}