Found bug in Image class GetStream Method

Jan 11, 2012 at 3:10 PM



In some cases the last line in the medhod cause exception:

        public Stream GetStream(FileMode mode, FileAccess access)
        {
            string temp = pr.SourceUri.OriginalString;
            string start = temp.Remove(temp.LastIndexOf('/'));
            string end = pr.TargetUri.OriginalString;

            // ALONMAT: FIX
            // if (end.IndexOf("/word/") == 0)
            //    end = end.Remove(0, 6);

            string full = start + "/" + end;

            return(document.package.GetPart(new Uri(full, UriKind.Relative)).GetStream(mode, access));
        }
here are the variable watches in good case:
temp = "/word/document.xml"
start = "/word"
end = "media/image1.png"
full = "/word/media/image1.png"
Here are the variable codes in bad case:
temp = "/word/document.xml"
start = "/word"
end = "/word/media/f0f8d79c-9f52-4803-849a-6581e475af60.png"
full = ""/word//word/media/f0f8d79c-9f52-4803-849a-6581e475af60.png"
In some cases the    'pr.TargetUri.OriginalString'  conatin additional 'word' on the path