Indefero

Indefero Commit Details


Date:2012-01-03 06:09:44 (13 years 3 months ago)
Author:Thomas Keller
Branch:develop, release-1.3
Commit:d32e17df91a19a701f05a90723146b0869b9d8b3
Parents: 51ca50ec3621c38af792a04f48010496d2aac038
Message:Actually validate project labels.

Changes:

File differences

src/IDF/Form/Admin/LabelConf.php
4444
4545
4646
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
4762
                                            'widget' => 'Pluf_Form_Widget_TextareaInput',
                                            ));
    }
    public function clean_project_labels()
    {
        $labels = preg_split("/\s*\n\s*/", $this->cleaned_data['project_labels'], -1, PREG_SPLIT_NO_EMPTY);
        for ($i=0; $i<count($labels); ++$i) {
            $labels[$i] = trim($labels[$i]);
            if (!preg_match('/^[\w-]+(:[\w-]+)?(\s*=\s*[^=]+)?$/', $labels[$i])) {
                throw new Pluf_Form_Invalid(sprintf(
                   __('The label "%s" is invalid: A label must only consist of alphanumeric '.
                      'characters and dashes, and can optionally contain a ":" with a group prefix.'),
                $labels[$i]));
            }
        }
        return implode("\n", $labels);
    }
}

Archive Download the corresponding diff file

Page rendered in 0.28987s using 13 queries.