Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch win-uri-fix Excluding Merge-Ins
This is equivalent to a diff from 96b8d81fe9 to fadeed7802
2018-07-23
| ||
10:28 | Merged the fixes for the scripted helper procs baseURL and extRefHandler for Windows paths containing drive letters provided by Ashok P. Nadkarni. check-in: 905eec2720 user: rolf tags: trunk | |
2018-07-22
| ||
08:50 |
Fix baseURL and extRefHandler for Windows paths containing drive letters.
Note that the tcllib uri package used by extRefHandler was broken until
V1.2.7. This version only tested with that version.
There is still an unrelated bug pending in that URI's are supposed to be url-encoded but the code does not currently handle that and will fail for special characters in the path. Closed-Leaf check-in: fadeed7802 user: apnadkarni tags: win-uri-fix | |
2018-07-20
| ||
09:58 | Merged from trunk. check-in: 401652dca9 user: rolf tags: nearerTEAtoThee | |
2018-07-19
| ||
12:53 | Create new branch named "win-uri-fix" check-in: 7e818a10f8 user: apnadkarni tags: win-uri-fix | |
00:42 | Fixed the test suite so that it should run without failure even if the build dir is outside the source tree. check-in: 96b8d81fe9 user: rolf tags: trunk | |
2018-07-18
| ||
14:41 | Attempt to make tdom::baseURI return "the right thing" for absolute paths on windows. check-in: b4d45b8409 user: rolf tags: trunk | |
Changes to lib/tdom.tcl.
944 944 not point to the foreign DTD" 945 945 } 946 946 } 947 947 set absolutURI [uri::resolve $base $systemId] 948 948 array set uriData [uri::split $absolutURI] 949 949 switch $uriData(scheme) { 950 950 file { 951 + if {$::tcl_platform(platform) eq "windows"} { 952 + # Strip leading / for drive based paths 953 + if {[string match /?:* $uriData(path)]} { 954 + set uriData(path) [string range $uriData(path) 1 end] 955 + } 956 + } 957 + # FIXME - path should be URL-decoded 951 958 return [list string $absolutURI [xmlReadFile $uriData(path)]] 952 959 } 953 960 default { 954 961 error "can only handle file URI's" 955 962 } 956 963 } 957 964 } ................................................................................ 960 967 #---------------------------------------------------------------------------- 961 968 # baseURL 962 969 # 963 970 # A simple convenience proc which returns an absolute URL for a given 964 971 # filename. 965 972 # 966 973 #---------------------------------------------------------------------------- 967 - 968 974 proc tdom::baseURL {path} { 969 - switch [file pathtype $path] { 970 - "relative" { 971 - return "file://[pwd]/$path" 972 - } 973 - default { 974 - if {[string index $path 0] ne "/"} { 975 - return "file:///$path" 976 - } else { 977 - return "file://$path" 978 - } 975 + # FIXME - path components need to be URL-encoded 976 + 977 + # Note [file join] will return path as is if it is already absolute. 978 + # Also on Windows, it will change \ -> /. This is necessary because 979 + # file URIs must always use /, never \. 980 + set path [file join [pwd] $path] 981 + 982 + if {$::tcl_platform(platform) ne "windows"} { 983 + return "file://$path" 984 + } else { 985 + if {[string match //* $path]} { 986 + # UNC path 987 + return "file:$path" 988 + } else { 989 + # Drive based path 990 + return "file:///$path" 979 991 } 980 992 } 981 993 } 982 994 983 995 namespace eval ::tDOM { 984 996 variable extRefHandlerDebug 0 985 997 variable useForeignDTD ""
Changes to tests/dom.test.
1050 1050 1051 1051 test dom-4.1 {-useForeignDTD 0} { 1052 1052 set doc [dom parse -useForeignDTD 0 {<root/>}] 1053 1053 $doc delete 1054 1054 } {} 1055 1055 1056 1056 test dom-4.2 {-useForeignDTD 1 with document with internal subset} {need_uri} { 1057 - set baseURI file://[file join [pwd] [file dir [info script]] dom.test] 1057 + set baseURI [tdom::baseURL [file join [pwd] [file dir [info script]] dom.test]] 1058 1058 set ::tdom::useForeignDTD "data/domCmd1.dtd" 1059 1059 set doc [dom parse \ 1060 1060 -useForeignDTD 1 \ 1061 1061 -baseurl $baseURI \ 1062 1062 -externalentitycommand ::tdom::extRefHandler { 1063 1063 <!DOCTYPE root [ 1064 1064 <!ATTLIST root fixed CDATA #FIXED "toThat"> ................................................................................ 1067 1067 set root [$doc documentElement] 1068 1068 set result [$root @fixed] 1069 1069 $doc delete 1070 1070 set result 1071 1071 } {toThat} 1072 1072 1073 1073 test dom-4.3 {-useForeignDTD 1 with document with internal subset} {need_uri} { 1074 - set baseURI file://[file join [pwd] [file dir [info script]] dom.test] 1074 + set baseURI [tdom::baseURL [file join [pwd] [file dir [info script]] dom.test]] 1075 1075 set ::tdom::useForeignDTD "data/domCmd1.dtd" 1076 1076 set doc [dom parse \ 1077 1077 -useForeignDTD 1 \ 1078 1078 -baseurl $baseURI \ 1079 1079 -externalentitycommand ::tdom::extRefHandler { 1080 1080 <!DOCTYPE root [ 1081 1081 <!ATTLIST root fixed2 CDATA #FIXED "toThat"> ................................................................................ 1085 1085 set result [$root @fixed] 1086 1086 lappend result [$root @fixed2] 1087 1087 $doc delete 1088 1088 set result 1089 1089 } {toThis toThat} 1090 1090 1091 1091 test dom-4.4 {-useForeignDTD 1 with document without document declaration} {need_uri} { 1092 - set baseURI file://[file join [pwd] [file dir [info script]] dom.test] 1092 + set baseURI [tdom::baseURL [file join [pwd] [file dir [info script]] dom.test]] 1093 1093 set ::tdom::useForeignDTD "data/domCmd1.dtd" 1094 1094 set doc [dom parse \ 1095 1095 -useForeignDTD 1 \ 1096 1096 -baseurl $baseURI \ 1097 1097 -externalentitycommand ::tdom::extRefHandler <root/>] 1098 1098 set root [$doc documentElement] 1099 1099 set result [$root @fixed] 1100 1100 $doc delete 1101 1101 set result 1102 1102 } {toThis} 1103 1103 1104 1104 test dom-4.5 {-useForeignDTD 1 does not overwrite a given external subset} {need_uri} { 1105 - set baseURI file://[file join [pwd] [file dir [info script]] dom.test] 1105 + set baseURI [tdom::baseURL [file join [pwd] [file dir [info script]] dom.test]] 1106 1106 set ::tdom::useForeignDTD "data/domCmd1.dtd" 1107 1107 set doc [dom parse \ 1108 1108 -useForeignDTD 1 \ 1109 1109 -baseurl $baseURI \ 1110 1110 -externalentitycommand ::tdom::extRefHandler { 1111 1111 <!DOCTYPE root SYSTEM "data/domCmd2.dtd"> 1112 1112 <root/>}] ................................................................................ 1118 1118 1119 1119 test dom-4.6 {-useForeignDTD with nonboolean arg} {need_uri} { 1120 1120 set result [catch {set doc [dom parse -useForeignDTD foo <root/>]} errMsg] 1121 1121 lappend result $errMsg 1122 1122 } {1 {expected boolean value but got "foo"}} 1123 1123 1124 1124 test dom-5.1 {document with external subset} {need_uri} { 1125 - set baseURI file://[file join [pwd] [file dir [info script]] dom.test] 1125 + set baseURI [tdom::baseURL [file join [pwd] [file dir [info script]] dom.test]] 1126 1126 set doc [dom parse \ 1127 1127 -baseurl $baseURI \ 1128 1128 -externalentitycommand ::tdom::extRefHandler { 1129 1129 <!DOCTYPE root SYSTEM "data/domCmd2.dtd"> 1130 1130 <root/>}] 1131 1131 set root [$doc documentElement] 1132 1132 set result [$root @fixed]
Changes to tests/domNode.test.
3020 3020 set result 3021 3021 } {1 NOT_FOUND_ERR} 3022 3022 3023 3023 test domNode-34.1 {getBaseURI} {need_uri} { 3024 3024 makeFile <y/> domNode-34.1-e1.xml [file join [file dir [info script]] data] 3025 3025 makeFile <y/> domNode-34.1-e2.xml [file join [file dir [info script]] data] 3026 3026 3027 - set baseURI file://[file join [pwd] [file dir [info script]] dom.test] 3027 + set baseURI [tdom::baseURL [file join [pwd] [file dir [info script]] dom.test]] 3028 3028 set doc [dom parse \ 3029 3029 -baseurl $baseURI \ 3030 3030 -externalentitycommand ::tdom::extRefHandler { 3031 3031 <!DOCTYPE x [ 3032 3032 <!ENTITY a SYSTEM "data/domNode-34.1-e1.xml"> 3033 3033 <!ENTITY b SYSTEM "data/domNode-34.1-e2.xml"> 3034 3034 ]> ................................................................................ 3052 3052 set result 3053 3053 } {1} 3054 3054 3055 3055 test domNode-34.2 {getBaseURI} {need_uri} { 3056 3056 makeFile <y/> domNode-34.1-e1.xml [file join [file dir [info script]] data] 3057 3057 makeFile <y/> domNode-34.1-e2.xml [file join [file dir [info script]] data] 3058 3058 3059 - set baseURI file://[file join [pwd] [file dir [info script]] dom.test] 3059 + set baseURI [tdom::baseURL [file join [pwd] [file dir [info script]] dom.test]] 3060 3060 set doc [dom parse \ 3061 3061 -baseurl $baseURI \ 3062 3062 -externalentitycommand ::tdom::extRefHandler { 3063 3063 <!DOCTYPE x [ 3064 3064 <!ENTITY a SYSTEM "data/domNode-34.1-e1.xml"> 3065 3065 <!ENTITY b SYSTEM "data/domNode-34.1-e2.xml"> 3066 3066 ]>