File tree Expand file tree Collapse file tree 3 files changed +39
-2
lines changed
itext.tests/itext.layout.tests/itext/layout Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Globalization ;
4+ using System . Linq ;
5+ using System . Text ;
6+ using System . Threading ;
7+ using iText . IO . Image ;
8+ using iText . Layout . Element ;
9+
10+ namespace iText . Layout
11+ {
12+ // This test is present only in c#
13+ class NetWorkPathTest
14+ {
15+ [ NUnit . Framework . Test ]
16+ public virtual void NetworkPathImageTest ( )
17+ {
18+ var fullImagePath = @"\\someVeryRandomWords\SomeVeryRandomName.img" ;
19+ string startOfMsg = null ;
20+ Thread . CurrentThread . CurrentCulture = CultureInfo . InvariantCulture ;
21+ Thread . CurrentThread . CurrentUICulture = CultureInfo . InvariantCulture ;
22+ try
23+ {
24+ Image drawing = new Image ( ImageDataFactory . Create ( fullImagePath ) ) ;
25+ }
26+ catch ( Exception e )
27+ {
28+ if ( e . InnerException != null && e . InnerException . Message . Length > 18 )
29+ startOfMsg = e . InnerException . Message . Substring ( 0 , 19 ) ;
30+ }
31+ NUnit . Framework . Assert . IsNotNull ( startOfMsg ) ;
32+ NUnit . Framework . Assert . AreNotEqual ( "Could not find file" , startOfMsg ) ;
33+ }
34+ }
35+ }
Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ public IRandomAccessSource CreateSource(FileStream raf)
153153 /// <exception cref="System.IO.IOException"/>
154154 public IRandomAccessSource CreateSource ( Uri url ) {
155155#if ! NETSTANDARD1_6
156- WebRequest wr = WebRequest . Create ( Uri . UnescapeDataString ( url . AbsoluteUri ) ) ;
156+ WebRequest wr = WebRequest . Create ( url . LocalPath ) ;
157157 wr . Credentials = CredentialCache . DefaultCredentials ;
158158 Stream isp = wr . GetResponse ( ) . GetResponseStream ( ) ;
159159#else
Original file line number Diff line number Diff line change @@ -71,7 +71,9 @@ public static Uri ToURL(String filename) {
7171 public static Stream OpenStream ( Uri url ) {
7272 Stream isp ;
7373 if ( url . IsFile ) {
74- isp = new FileStream ( Uri . UnescapeDataString ( url . AbsolutePath ) , FileMode . Open , FileAccess . Read ) ;
74+ // do not replace first argument with Uri.UnescapeDataString(url.AbsolutePath) instead of url.LocalPath
75+ // it breaks the recognition of network paths
76+ isp = new FileStream ( url . LocalPath , FileMode . Open , FileAccess . Read ) ;
7577 } else {
7678#if ! NETSTANDARD1_6
7779 WebRequest req = WebRequest . Create ( url ) ;
You can’t perform that action at this time.
0 commit comments