The Inbox: Network-topa.70.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Network-topa.70.mcz

commits-2
A new version of Network was added to project The Inbox:
http://source.squeak.org/inbox/Network-topa.70.mcz

==================== Summary ====================

Name: Network-topa.70
Author: topa
Time: 4 May 2010, 2:40:49.919 pm
UUID: 910cd7d2-0bf9-4f74-95ec-4f290a58235d
Ancestors: Network-ar.69

Allow for Urls that might contain passwords/usernames with
"dangerous" characters.


=============== Diff against Network-ar.69 ===============

Item was changed:
  ----- Method: HierarchicalUrl>>privateInitializeFromText: (in category 'parsing') -----
  privateInitializeFromText: aString
  | remainder ind specifiedSchemeName |
  remainder := aString.
  schemeName ifNil:
  [specifiedSchemeName := Url schemeNameForString: remainder.
  specifiedSchemeName ifNotNil:
  [schemeName := specifiedSchemeName.
  remainder := remainder copyFrom: schemeName size + 2 to: remainder size].
  schemeName ifNil:
  ["assume HTTP"
 
  schemeName := 'http']].
 
  "remove leading // if it's there"
  (remainder beginsWith: '//')
  ifTrue: [remainder := remainder copyFrom: 3 to: remainder size].
 
 
  "get the query"
  ind := remainder indexOf: $?.
  ind > 0
  ifTrue:
  [query := remainder copyFrom: ind + 1 to: remainder size.
  remainder := remainder copyFrom: 1 to: ind - 1].
 
  "get the authority"
  ind := remainder indexOf: $/.
  ind > 0
  ifTrue:
  [ind = 1
  ifTrue: [authority := '']
  ifFalse:
  [authority := remainder copyFrom: 1 to: ind - 1.
  remainder := remainder copyFrom: ind + 1 to: remainder size]]
  ifFalse:
  [authority := remainder.
  remainder := ''].
 
  "extract the username+password"
  (authority includes: $@)
  ifTrue:
  [username := authority copyUpTo: $@.
  authority := authority copyFrom: (authority indexOf: $@) + 1
  to: authority size.
  (username includes: $:)
  ifTrue:
+ [password := (username copyFrom: (username indexOf: $:) + 1 to: username size) unescapePercents.
+ username := username copyUpTo: $:].
+ username := username unescapePercents].
- [password := username copyFrom: (username indexOf: $:) + 1 to: username size.
- username := username copyUpTo: $:]].
 
  "Extract the port"
  (authority includes: $:)
  ifTrue:
  [| lastColonIndex portString |
  lastColonIndex := authority findLast: [:c | c = $:].
  portString := authority copyFrom: lastColonIndex + 1 to: authority size.
  portString isAllDigits
  ifTrue:
  [port := Integer readFromString: portString.
  (port > 65535) ifTrue: [self error: 'Invalid port number'].
  authority := authority copyFrom: 1 to: lastColonIndex - 1]
  ifFalse:[self error: 'Invalid port number']].
 
  "get the path"
  path := self privateParsePath: remainder relativeTo: #() .!