summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2016-03-07 15:01:13 +0000
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2016-03-07 15:01:19 +0000
commitbf2c0c340526375217796df18a52f4c08e2344d4 (patch)
tree7e7764c8fdaed22af9435cb9178af7d7ba90b865
parent2ae279060436e500b5605a13c919cd51f4344460 (diff)
eolian: validate eo/legacy prefix to be [a-z_][a-z0-9_]*
-rw-r--r--src/lib/eolian/eo_parser.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index a0d9ddd814..c16019e8fe 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -1643,6 +1643,30 @@ parse_events(Eo_Lexer *ls)
1643} 1643}
1644 1644
1645static void 1645static void
1646_validate_pfx(Eo_Lexer *ls)
1647{
1648 char ebuf[PATH_MAX];
1649 check(ls, TOK_VALUE);
1650 const char *str = ls->t.value.s;
1651 if ((*str != '_') && ((*str < 'a') || (*str > 'z')))
1652 goto error;
1653 for (++str; *str; ++str)
1654 {
1655 if (*str == '_')
1656 continue;
1657 if ((*str >= 'a') && (*str <= 'z'))
1658 continue;
1659 if ((*str >= '0') && (*str <= '9'))
1660 continue;
1661 goto error;
1662 }
1663 return;
1664error:
1665 snprintf(ebuf, sizeof(ebuf), "invalid prefix '%s'", ls->t.value.s);
1666 eo_lexer_syntax_error(ls, ebuf);
1667}
1668
1669static void
1646parse_class_body(Eo_Lexer *ls, Eolian_Class_Type type) 1670parse_class_body(Eo_Lexer *ls, Eolian_Class_Type type)
1647{ 1671{
1648 Eina_Bool has_legacy_prefix = EINA_FALSE, 1672 Eina_Bool has_legacy_prefix = EINA_FALSE,
@@ -1663,7 +1687,7 @@ parse_class_body(Eo_Lexer *ls, Eolian_Class_Type type)
1663 CASE_LOCK(ls, legacy_prefix, "legacy prefix definition") 1687 CASE_LOCK(ls, legacy_prefix, "legacy prefix definition")
1664 eo_lexer_get(ls); 1688 eo_lexer_get(ls);
1665 check_next(ls, ':'); 1689 check_next(ls, ':');
1666 check(ls, TOK_VALUE); 1690 _validate_pfx(ls);
1667 ls->tmp.kls->legacy_prefix = eina_stringshare_ref(ls->t.value.s); 1691 ls->tmp.kls->legacy_prefix = eina_stringshare_ref(ls->t.value.s);
1668 eo_lexer_get(ls); 1692 eo_lexer_get(ls);
1669 check_next(ls, ';'); 1693 check_next(ls, ';');
@@ -1672,7 +1696,7 @@ parse_class_body(Eo_Lexer *ls, Eolian_Class_Type type)
1672 CASE_LOCK(ls, eo_prefix, "eo prefix definition") 1696 CASE_LOCK(ls, eo_prefix, "eo prefix definition")
1673 eo_lexer_get(ls); 1697 eo_lexer_get(ls);
1674 check_next(ls, ':'); 1698 check_next(ls, ':');
1675 check(ls, TOK_VALUE); 1699 _validate_pfx(ls);
1676 ls->tmp.kls->eo_prefix = eina_stringshare_ref(ls->t.value.s); 1700 ls->tmp.kls->eo_prefix = eina_stringshare_ref(ls->t.value.s);
1677 eo_lexer_get(ls); 1701 eo_lexer_get(ls);
1678 check_next(ls, ';'); 1702 check_next(ls, ';');