func newJournalArgsFromURL(query url.Values) (*journalArgs, error) {
	since, err := validJournalDateRange(query.Get("since"))
	if err != nil {
		return nil, fmt.Errorf("parameter 'since' is invalid: %v", err)
	}
	until, err := validJournalDateRange(query.Get("until"))
	if err != nil {
		return nil, fmt.Errorf("parameter 'until' is invalid: %v", err)
	}
	format, err := stringInSlice(query.Get("output"), "short-precise", "json", "short", "short-unix", "short-iso", "short-iso-precise", "cat", "")
	if err != nil {
		return nil, fmt.Errorf("parameter 'output' is invalid: %v", err)
	}
	if len(format) == 0 {
		format = "short-precise"
	}
	units, err := safeStrings(query["unit"])
	if err != nil {
		return nil, fmt.Errorf("parameter 'unit' is invalid: %v", err)
	}
	var boot *int
	if bootStr := query.Get("boot"); len(bootStr) > 0 {
		boot, err = validIntRange(bootStr, -100, 0)
		if err != nil {
			return nil, fmt.Errorf("parameter 'boot' is invalid: %v", err)
		}
	}
	pattern, err := safeString(query.Get("grep"))
	if err != nil {
		return nil, fmt.Errorf("parameter 'grep' is invalid: %v", err)
	}

	// All parameters loaded from the query must be thoroughly sanitized - do
	// not pass query parameters directly to journalctl without limiting them
	// as demonstrated above.
	return &journalArgs{
		Units: units,

		Since: since,
		Until: until,
		Tail:  boundedIntegerOrDefault(query.Get("tail"), 0, 100000, 0),
		Boot:  boot,

		Timeout: boundedIntegerOrDefault(query.Get("timeout"), 1, 60, 30),

		Pattern:       pattern,
		CaseSensitive: boolean(query.Get("case-sensitive"), true),

		Format: format,
	}, nil
}
// newJournalArgsFromURL returns bounds checked values based on query
// parameters. Parameter names are deliberately chosen to align with
// journalctl arguments. If journalctl ever creates incompatible arguments,
// this method should introduce new parameters that preserves compatibility.
newJournalArgsFromURL returns bounds checked values based on query
parameters. Parameter names are deliberately chosen to align with
journalctl arguments. If journalctl ever creates incompatible arguments,
this method should introduce new parameters that preserves compatibility.
// newJournalArgsFromURL returns bounds checked values based on query // parameters . Parameter names are deliberately chosen to align with // journalctl arguments . If journalctl ever creates incompatible arguments // this method should introduce new parameters that preserves compatibility .
func newJournalArgsFromURL(query url.Values) (*journalArgs, error) {
	since, err := validJournalDateRange(query.Get("since"))
	if err != nil {
		return nil, fmt.Errorf("parameter 'since' is invalid: %v", err)
	}
	until, err := validJournalDateRange(query.Get("until"))
	if err != nil {
		return nil, fmt.Errorf("parameter 'until' is invalid: %v", err)
	}
	format, err := stringInSlice(query.Get("output"), "short-precise", "json", "short", "short-unix", "short-iso", "short-iso-precise", "cat", "")
	if err != nil {
		return nil, fmt.Errorf("parameter 'output' is invalid: %v", err)
	}
	if len(format) == 0 {
		format = "short-precise"
	}
	units, err := safeStrings(query["unit"])
	if err != nil {
		return nil, fmt.Errorf("parameter 'unit' is invalid: %v", err)
	}
	var boot *int
	if bootStr := query.Get("boot"); len(bootStr) > 0 {
		boot, err = validIntRange(bootStr, -100, 0)
		if err != nil {
			return nil, fmt.Errorf("parameter 'boot' is invalid: %v", err)
		}
	}
	pattern, err := safeString(query.Get("grep"))
	if err != nil {
		return nil, fmt.Errorf("parameter 'grep' is invalid: %v", err)
	}
	return &journalArgs{
		Units: units,
		Since: since,
		Until: until,
		Tail:  boundedIntegerOrDefault(query.Get("tail"), 0, 100000, 0),
		Boot:  boot,
		Timeout: boundedIntegerOrDefault(query.Get("timeout"), 1, 60, 30),
		Pattern:       pattern,
		CaseSensitive: boolean(query.Get("case-sensitive"), true),
		Format: format,
	}, nil
}
func newJournalArgsFromURL ( query url . Values ) ( * journalArgs , error ) { since , err := validJournalDateRange ( query . Get ( " " ) ) if err != nil { return nil , fmt . Errorf ( " " , err ) } until , err := validJournalDateRange ( query . Get ( " " ) ) if err != nil { return nil , fmt . Errorf ( " " , err ) } format , err := stringInSlice ( query . Get ( " " ) , " " , " " , " " , " " , " " , " " , " " , " " ) if err != nil { return nil , fmt . Errorf ( " " , err ) } if len ( format ) == 0 { format = " " } units , err := safeStrings ( query [ " " ] ) if err != nil { return nil , fmt . Errorf ( " " , err ) } var boot * int if bootStr := query . Get ( " " ) ; len ( bootStr ) > 0 { boot , err = validIntRange ( bootStr , - 100 , 0 ) if err != nil { return nil , fmt . Errorf ( " " , err ) } } pattern , err := safeString ( query . Get ( " " ) ) if err != nil { return nil , fmt . Errorf ( " " , err ) } return & journalArgs { Units : units , Since : since , Until : until , Tail : boundedIntegerOrDefault ( query . Get ( " " ) , 0 , 100000 , 0 ) , Boot : boot , Timeout : boundedIntegerOrDefault ( query . Get ( " " ) , 1 , 60 , 30 ) , Pattern : pattern , CaseSensitive : boolean ( query . Get ( " " ) , true ) , Format : format , } , nil }
newJournalArgsFromURL returns bounds checked values based on query
parameters.
newJournalArgsFromURL returns bounds checked values based on query parameters .
// All parameters loaded from the query must be thoroughly sanitized - do // not pass query parameters directly to journalctl without limiting them // as demonstrated above.