Skip to content

Commit

Permalink
Merge pull request #87 from JM-Lemmi/fix/text_escaping
Browse files Browse the repository at this point in the history
Revert incorrect text escaping patch.
  • Loading branch information
arran4 authored Feb 15, 2024
2 parents 542d6e5 + bb39d64 commit 0fcebed
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
8 changes: 4 additions & 4 deletions calendar.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,19 +317,19 @@ func (calendar *Calendar) SerializeTo(w io.Writer) error {
}

func (calendar *Calendar) SetMethod(method Method, props ...PropertyParameter) {
calendar.setProperty(PropertyMethod, string(method), props...)
calendar.setProperty(PropertyMethod, ToText(string(method)), props...)
}

func (calendar *Calendar) SetXPublishedTTL(s string, props ...PropertyParameter) {
calendar.setProperty(PropertyXPublishedTTL, string(s), props...)
}

func (calendar *Calendar) SetVersion(s string, props ...PropertyParameter) {
calendar.setProperty(PropertyVersion, s, props...)
calendar.setProperty(PropertyVersion, ToText(s), props...)
}

func (calendar *Calendar) SetProductId(s string, props ...PropertyParameter) {
calendar.setProperty(PropertyProductId, s, props...)
calendar.setProperty(PropertyProductId, ToText(s), props...)
}

func (calendar *Calendar) SetName(s string, props ...PropertyParameter) {
Expand Down Expand Up @@ -358,7 +358,7 @@ func (calendar *Calendar) SetXWRCalID(s string, props ...PropertyParameter) {
}

func (calendar *Calendar) SetDescription(s string, props ...PropertyParameter) {
calendar.setProperty(PropertyDescription, s, props...)
calendar.setProperty(PropertyDescription, ToText(s), props...)
}

func (calendar *Calendar) SetLastModified(t time.Time, props ...PropertyParameter) {
Expand Down
25 changes: 25 additions & 0 deletions calendar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,31 @@ ATTENDEE;CN=Test\;User:mailto:[email protected]
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR
`,
},
{
name: "test RRULE escaping",
input: `BEGIN:VCALENDAR
VERSION:2.0
X-CUSTOM-FIELD:test
PRODID:-//arran4//Golang ICS Library
DESCRIPTION:test
BEGIN:VEVENT
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=SU
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR
`,
output: `BEGIN:VCALENDAR
VERSION:2.0
X-CUSTOM-FIELD:test
PRODID:-//arran4//Golang ICS Library
DESCRIPTION:test
BEGIN:VEVENT
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=SU
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR
`,
},
}
Expand Down
8 changes: 4 additions & 4 deletions components.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,19 @@ func (cb *ComponentBase) GetDtStampTime() (time.Time, error) {
}

func (cb *ComponentBase) SetSummary(s string, props ...PropertyParameter) {
cb.SetProperty(ComponentPropertySummary, s, props...)
cb.SetProperty(ComponentPropertySummary, ToText(s), props...)
}

func (cb *ComponentBase) SetStatus(s ObjectStatus, props ...PropertyParameter) {
cb.SetProperty(ComponentPropertyStatus, string(s), props...)
cb.SetProperty(ComponentPropertyStatus, ToText(string(s)), props...)
}

func (cb *ComponentBase) SetDescription(s string, props ...PropertyParameter) {
cb.SetProperty(ComponentPropertyDescription, s, props...)
cb.SetProperty(ComponentPropertyDescription, ToText(s), props...)
}

func (cb *ComponentBase) SetLocation(s string, props ...PropertyParameter) {
cb.SetProperty(ComponentPropertyLocation, s, props...)
cb.SetProperty(ComponentPropertyLocation, ToText(s), props...)
}

func (cb *ComponentBase) setGeo(lat interface{}, lng interface{}, props ...PropertyParameter) {
Expand Down
2 changes: 1 addition & 1 deletion property.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (property *BaseProperty) serialize(w io.Writer) {
}
}
fmt.Fprint(b, ":")
fmt.Fprint(b, ToText(property.Value))
fmt.Fprint(b, property.Value)
r := b.String()
if len(r) > 75 {
l := trimUT8StringUpTo(75, r)
Expand Down

0 comments on commit 0fcebed

Please sign in to comment.