The Trunk: Collections-mt.705.mcz

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

The Trunk: Collections-mt.705.mcz

commits-2
Marcel Taeumel uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-mt.705.mcz

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

Name: Collections-mt.705
Author: mt
Time: 11 August 2016, 4:29:13.490564 pm
UUID: fbaaa045-4df3-c746-9de5-d8102495a1e3
Ancestors: Collections-mt.704

Fix two small bugs in HTML parser regarding strings in tag properties and href contents.

=============== Diff against Collections-mt.704 ===============

Item was changed:
  ----- Method: HtmlReadWriter>>mapATag: (in category 'mapping') -----
  mapATag: aTag
 
  | result startIndex stopIndex attribute |
  result := OrderedCollection new.
 
  "<a href=""http://google.de"">"
  attribute := 'href'.
  startIndex := aTag findString: attribute.
  startIndex > 0 ifTrue: [
+ startIndex := aTag findString: '"' startingAt: startIndex+attribute size.
+ stopIndex := aTag findString: '"' startingAt: startIndex+1.
- startIndex := aTag findString: '=' startingAt: startIndex+attribute size.
- stopIndex := aTag findString: ' ' startingAt: startIndex+1.
- stopIndex = 0 ifTrue: [
- stopIndex := aTag findString: '>' startingAt: startIndex+1].
-
- (aTag at: startIndex + 1) = $"
- ifTrue: [startIndex := startIndex + 1].
- (aTag at: stopIndex - 1) = $"
- ifTrue: [stopIndex := stopIndex - 1].
  result add: (TextURL new url: (aTag copyFrom: startIndex+1 to: stopIndex-1))].
 
  ^ result!

Item was changed:
  ----- Method: HtmlReadWriter>>processNextTag (in category 'reading') -----
  processNextTag
 
+ | tag htmlEscape lookForNewTag lookForHtmlEscape tagFound valid inComment inTagString |
- | tag htmlEscape lookForNewTag lookForHtmlEscape tagFound valid inComment |
  lookForNewTag := true.
  lookForHtmlEscape := false.
  tagFound := false.
  tag := OrderedCollection new.
  htmlEscape := OrderedCollection new.
  inComment := false.
+ inTagString := false.
 
  [stream atEnd not and: [tagFound not]] whileTrue: [
  | character |
  character := stream next.
  valid := (#(10 13) includes: character asciiValue) not.
  count := count + 1.
 
  character = $< ifTrue: [lookForNewTag := false].
  character = $& ifTrue: [
  inComment ifFalse: [lookForHtmlEscape := true]].
 
  lookForNewTag
  ifTrue: [
  lookForHtmlEscape
  ifFalse: [valid ifTrue: [string add: character] ifFalse: [offset := offset + 1]]
  ifTrue: [valid ifTrue: [htmlEscape add: character]. offset := offset + 1]]
  ifFalse: [valid ifTrue: [tag add: character]. offset := offset + 1].
 
+ "Toggle within tag string/text."
+ (character = $" and: [lookForNewTag not])
+ ifTrue: [inTagString := inTagString not].
+
  inComment := ((lookForNewTag not and: [tag size >= 4])
  and: [tag beginsWith: '<!!--'])
  and: [(tag endsWith: '-->') not].
 
+ (((character = $> and: [inComment not]) and: [lookForNewTag not]) and: [inTagString not]) ifTrue: [
- ((character = $> and: [inComment not]) and: [lookForNewTag not]) ifTrue: [
  lookForNewTag := true.
  (tag beginsWith: '<!!--')
  ifTrue: [self processComment: (String withAll: tag)]
  ifFalse: [tag second ~= $/
  ifTrue: [
  (tag atLast: 2) == $/
  ifTrue: [self processEmptyTag: (String withAll: tag)]
  ifFalse: [self processStartTag: (String withAll: tag)]]
  ifFalse: [self processEndTag: (String withAll: tag)]].
  tagFound := true].
 
  (((character = $; and: [lookForNewTag])
  and: [htmlEscape notEmpty]) and: [htmlEscape first = $&]) ifTrue: [
  lookForHtmlEscape := false.
  self processHtmlEscape: (String withAll: htmlEscape).
  htmlEscape := OrderedCollection new]].
  !