Bug 1448945 - Allow underscore in category, method and extra keys of event. r=chutten

According to the documnetation[1] category and method are identifiers,
thus an underscore is allowed. It's less clear for extra keys, but
underscores are already used there.

The documentation is adjusted accordingly.

[1]: https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/collection/events.html#limits

MozReview-Commit-ID: 9pUsDNXCY8m
This commit is contained in:
Jan-Erik Rediger
2018-04-10 13:05:39 +02:00
parent af5cde507e
commit 4b94fa0f85
2 changed files with 4 additions and 4 deletions

View File

@@ -981,7 +981,7 @@ TelemetryEvent::RegisterEvents(const nsACString& aCategory,
MOZ_ASSERT(XRE_IsParentProcess(),
"Events can only be registered in the parent process");
if (!IsValidIdentifierString(aCategory, 30, true, false)) {
if (!IsValidIdentifierString(aCategory, 30, true, true)) {
JS_ReportErrorASCII(cx, "Category parameter should match the identifier pattern.");
return NS_ERROR_INVALID_ARG;
}
@@ -1065,7 +1065,7 @@ TelemetryEvent::RegisterEvents(const nsACString& aCategory,
// Validate methods.
for (auto& method : methods) {
if (!IsValidIdentifierString(method, kMaxMethodNameByteLength, false, false)) {
if (!IsValidIdentifierString(method, kMaxMethodNameByteLength, false, true)) {
JS_ReportErrorASCII(cx, "Method names should match the identifier pattern.");
return NS_ERROR_INVALID_ARG;
}
@@ -1085,7 +1085,7 @@ TelemetryEvent::RegisterEvents(const nsACString& aCategory,
return NS_ERROR_INVALID_ARG;
}
for (auto& key : extra_keys) {
if (!IsValidIdentifierString(key, kMaxExtraKeyNameByteLength, false, false)) {
if (!IsValidIdentifierString(key, kMaxExtraKeyNameByteLength, false, true)) {
JS_ReportErrorASCII(cx, "Extra key names should match the identifier pattern.");
return NS_ERROR_INVALID_ARG;
}