GNOME Bugzilla – Bug 607229
Opening large files
Last modified: 2011-08-12 00:28:56 UTC
Opening large files should be detected, showing a warning, as a common error is to choose the video instead of subtitles' file. Perhaps detect if it is plain-text too.
[version 1.1] Exactly. My machine with 1GByte main memory `died' after coincidentally trying to open an 8GByte DV file...
Pedro, to dictionary check the type you do on 2 kb, and check the coding on the whole file. I propose two restrictions: 1. When you open the file (GUI) check the size eg > 1MB file will not subtitles. 2. In SubLib check encoding limited to 2 or 10 KB, but thoroughly, the samples need it yourself you'll know best. [SubLibGUI] Windows System.OutOfMemoryException: Zgłoszono wyjątek typu 'System.OutOfMemoryException'. w System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity) w System.Text.StringBuilder.GetNewString(String currentString, Int32 requiredLength) w System.Text.StringBuilder.Append(Char[] value, Int32 startIndex, Int32 charCount) w System.IO.StreamReader.ReadToEnd() w SubLib.IO.FileInputOutput.ReadFile(FileStream file, Encoding encoding, Boolean reposition) w c:\_Sharp\SubLib\SubLibDLL11x\SubLib\IO\FileInputOutput.cs:wiersz 76 w SubLib.IO.Input.SubtitleInput.TestEncoding(FileStream fileStream, Encoding encoding) w c:\_Sharp\SubLib\SubLibDLL11x\SubLib\IO\Input\SubtitleInput.cs:wiersz 188 w SubLib.IO.Input.SubtitleInput.TestEncoding(FileStream fileStream, Encoding encoding, SubtitleFormat& format) w c:\_Sharp\SubLib\SubLibDLL11x\SubLib\IO\Input\SubtitleInput.cs:wiersz 177 w SubLib.IO.Input.SubtitleInput.TestCodePage(FileStream fileStream, Int32 codePage, Encoding& encoding, SubtitleFormat& format) w c:\_Sharp\SubLib\SubLibDLL11x\SubLib\IO\Input\SubtitleInput.cs:wiersz 154 w SubLib.IO.Input.SubtitleInput.ReadSubtitleText(Boolean isSubtitleFile, FileStream fileStream, Encoding& usedEncoding, SubtitleFormat& usedFormat) w c:\_Sharp\SubLib\SubLibDLL11x\SubLib\IO\Input\SubtitleInput.cs:wiersz 113 w SubLib.IO.Input.SubtitleInput.Read(String path, Encoding& encoding, SubtitleFormat& format) w c:\_Sharp\SubLib\SubLibDLL11x\SubLib\IO\Input\SubtitleInput.cs:wiersz 45 w SubLib.Core.SubtitleFactory.Open(String path) w c:\_Sharp\SubLib\SubLibDLL11x\SubLib\Core\SubtitleFactory.cs:wiersz 119 w SubLibGUI11.MainForm.OpenSubtitlesFile() w c:\_Sharp\SubLib\SubLibGUI11\MainForm.cs:wiersz 200 from: internal class FileInputOutput: internal static string ReadFile (FileStream file, Encoding encoding, bool reposition) { StreamReader reader = new StreamReader(file, encoding, false); #76>>> string text = reader.ReadToEnd(); if (reposition) file.Seek(0, SeekOrigin.Begin); return ConvertNewLinesToUnix(text); }
Created attachment 189116 [details] [review] Patch for #607229 File size limitation I calculated like this: The largest subtitle file I found was to 75kB, 100kB rounded. 100kb x 10 = 1MB. There should be no larger files. If I am wrong, please correct.
Hi there Pawel, thanks for your patch. I made some very small adjustments: 1) allow to configure the maximum file size limit in SubtitleFactory 2) call Catalog.GetString("myString") instead of Catalog.GetString(myStringVariable) so gettext can find the string You can view the commit log here: http://git.gnome.org/browse/gnome-subtitles/commit/?id=22bfffd0187e7610c7f04804c7afee2b6f314d08 Cheers and thanks again.
*** Bug 656168 has been marked as a duplicate of this bug. ***