Function: icalendar-parse-param-value

icalendar-parse-param-value is a byte-compiled function defined in icalendar-parser.el.gz.

Signature

(icalendar-parse-param-value TYPE LIMIT)

Documentation

Parse the value for a parameter of type TYPE from point up to LIMIT.

TYPE should be a type symbol for an iCalendar parameter type. This function expects point to be at the start of the value string, after the parameter name and the equals sign. Returns a syntax node representing the parameter.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar-parser.el.gz
(defun ical:parse-param-value (type limit)
  "Parse the value for a parameter of type TYPE from point up to LIMIT.
TYPE should be a type symbol for an iCalendar parameter type.
This function expects point to be at the start of the value
string, after the parameter name and the equals sign.  Returns a
syntax node representing the parameter."
  (let ((full-value-regex (rx-to-string (get type 'ical:full-value-rx))))
    ;; By far the most common invalid data seem to be text values that
    ;; contain unescaped characters (e.g. commas in addresses).  These
    ;; are harmless as long as the parameter accepts arbitrary text and
    ;; does not expect a list of values.  The only such parameter
    ;; defined in RFC5545 is `ical:cnparam', so we treat this as a
    ;; special case and loosen the official regexp to accept anything up
    ;; to the start of the next param or property value:
    (when (and (eq type 'ical:cnparam)
               (not ical:parse-strictly))
      (setq full-value-regex
            (rx (group-n 2 (or ical:quoted-string
                               (zero-or-more (not (any ?: ?\;))))))))

    (unless (re-search-forward full-value-regex limit t)
      (ical:signal-parse-error
       (format "Unable to parse `%s' value between %d and %d"
               type (point) limit)))
    (when (match-string 3)
      (ical:signal-parse-error
       (format "Invalid value for `%s' parameter: %s" type (match-string 3))))

    (let ((value-begin (match-beginning 2))
          (value-end (match-end 2))
          (node (ical:read-param-value type (match-string 2))))
      (ical:ast-node-meta-set node :buffer (current-buffer))
      ;; :begin must be set by parse-params
      (ical:ast-node-meta-set node :value-begin value-begin)
      (ical:ast-node-meta-set node :value-end value-end)
      (ical:ast-node-meta-set node :end value-end)

      node)))