Giter Site home page Giter Site logo

go-ical's Introduction

go-ical

GoDoc builds.sr.ht status

An iCalendar library for Go.

License

MIT

go-ical's People

Contributors

brunnre8 avatar emersion avatar kwo avatar whynothugo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

go-ical's Issues

Reading in-file timezones

I've a lot of events that look like this:

BEGIN:VCALENDAR
PRODID:-//Radicale//NONSGML Radicale Server//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:local
X-RADICALE-NAME:local
BEGIN:STANDARD
DTSTART:20090314T230000
TZNAME:ART
TZOFFSETFROM:-0200
TZOFFSETTO:-0300
X-RADICALE-NAME:local
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
SUMMARY:Redacted summary
DTSTART;TZID="local;VALUE=DATE-TIME":20150315T123000
DTEND;TZID="local;VALUE=DATE-TIME":20150315T193000
DTSTAMP:20150315T103349Z
UID:762CJK7VMGEBP416C5TE3V6KFHVJXY2Y6IPD
SEQUENCE:0
X-RADICALE-NAME:762CJK7VMGEBP416C5TE3V6KFHVJXY2Y6IPD.ics
END:VEVENT
END:VCALENDAR

This doesn't seem to be invalid; the timezone is specific in the file. However, parsing these returns error unknown time zone local.

RFC line length is not support when encoding

As RFC5545 states:

Lines of text SHOULD NOT be longer than 75 octets, excluding the line break. Long content lines SHOULD be split into a multiple line representations using a line "folding" technique.

This is currently not supported. Lines are completely posted into the output without folding.

Expose escaping

Hi,

Prop.SetText() applies value escaping through Prop.SetTextList(). However it's currently too opinionated to use a general value escaping. I propose to open up the escaping, te be re-used for more complex situations:

// Potentially problematic, since none of the parameters or the value is escaped.
e.Props.Set(&ical.Prop{
	Name: ical.PropOrganizer,
	Params: ical.Params{
		ical.ParamCommonName: []string{organiser.Name},
	},
	Value: fmt.Sprintf("MAILTO:%s", organizer.EmailAddress),
})

Now we need to duplicate the escaping functionality to make sure that the value passed here is also properly escaped. Ideally I would like to see an ical.EscapeValue() which does so that there can be consistent escaping.

func EscapeValue(s string) string {

	var sb strings.Builder
	sb.Grow(len(s))

	for _, r := range s {
		switch r {
		default:
			sb.WriteRune(r)

		case '\\', ';', ',':
			sb.WriteByte('\\')
			sb.WriteRune(r)
		case '\n':
			sb.WriteString(`\n`)
		// Should \r's be written at all, or is it safe to skip these?
		case '\r':
			continue

		}
	}

	return sb.String()
}

Properties defined with Props.Set() aren't escaped

In line of our earlier discussion, escaping should happen without the user having to think about it. At the moment this isn't yet the case. The following two pieces of code have a different result:

e.Props.Set(&ical.Prop{
	Name:  ical.PropDescription,
	Value: `Hello world!\n-:-;`,
})
// produces: Hello world!\n-:-;
e.Props.SetText(ical.PropDescription, `Hello world!\n-:-;`)
// produces: Hello world!\\n-:-\;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.