After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 607229 - Opening large files
Opening large files
Status: RESOLVED FIXED
Product: gnome-subtitles
Classification: Other
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: Maintainers of GNOME subtitles
Maintainers of GNOME subtitles
Depends on:
Blocks:
 
 
Reported: 2010-01-17 16:09 UTC by Pedro Castro
Modified: 2011-08-12 00:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for #607229 (3.26 KB, patch)
2011-06-02 19:21 UTC, Pawel57
none Details | Review

Description Pedro Castro 2010-01-17 16:09:07 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.
Comment 1 Werner Lemberg 2010-12-15 11:42:08 UTC
[version 1.1]

Exactly.  My machine with 1GByte main memory `died' after coincidentally trying to open an 8GByte DV file...
Comment 2 Pawel57 2011-02-27 01:39:58 UTC
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);
	}
Comment 3 Pawel57 2011-06-02 19:21:02 UTC
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.
Comment 4 Pedro Castro 2011-06-14 22:24:24 UTC
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.
Comment 5 Pedro Castro 2011-08-12 00:28:56 UTC
*** Bug 656168 has been marked as a duplicate of this bug. ***