From 2f57a0b917478a028859b9d036b59cf1bba6cad2 Mon Sep 17 00:00:00 2001
From: Caratpine <bepox0531@gmail.com>
Date: Sat, 19 Aug 2017 11:41:03 +0800
Subject: [PATCH] Blueprint view function name should not contain dots

---
 CHANGES                  | 2 ++
 flask/blueprints.py      | 2 ++
 tests/test_blueprints.py | 9 +++++++++
 3 files changed, 13 insertions(+)

diff --git a/CHANGES b/CHANGES
index cb0579cb9a..357b289d1a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -112,6 +112,7 @@ Major release, unreleased
   ``app.debug`` each time. Only one format is used, not different ones
   depending on ``app.debug``. No handlers are removed, and a handler is only
   added if no handlers are already configured. (`#2436`_)
+- Blueprint view function name may not contain dots. (`#2450`_)
 
 .. _#1421: https://github.com/pallets/flask/issues/1421
 .. _#1489: https://github.com/pallets/flask/pull/1489
@@ -144,6 +145,7 @@ Major release, unreleased
 .. _#2416: https://github.com/pallets/flask/pull/2416
 .. _#2430: https://github.com/pallets/flask/pull/2430
 .. _#2436: https://github.com/pallets/flask/pull/2436
+.. _#2450: https://github.com/pallets/flask/pull/2450
 
 Version 0.12.2
 --------------
diff --git a/flask/blueprints.py b/flask/blueprints.py
index 80668dbef8..4c9938e2f0 100644
--- a/flask/blueprints.py
+++ b/flask/blueprints.py
@@ -198,6 +198,8 @@ def add_url_rule(self, rule, endpoint=None, view_func=None, **options):
         """
         if endpoint:
             assert '.' not in endpoint, "Blueprint endpoints should not contain dots"
+        if view_func:
+            assert '.' not in view_func.__name__, "Blueprint view function name should not contain dots"
         self.record(lambda s:
             s.add_url_rule(rule, endpoint, view_func, **options))
 
diff --git a/tests/test_blueprints.py b/tests/test_blueprints.py
index d57b303447..c58a0d3ba6 100644
--- a/tests/test_blueprints.py
+++ b/tests/test_blueprints.py
@@ -360,6 +360,15 @@ def foo_foo_foo():
         lambda: None
     )
 
+    foo_foo_foo.__name__ = 'bar.123'
+
+    pytest.raises(
+        AssertionError,
+        lambda: bp.add_url_rule(
+            '/bar/123', view_func=foo_foo_foo
+        )
+    )
+
     app.register_blueprint(bp, url_prefix='/py')
 
     assert client.get('/py/foo').data == b'bp.foo'