Index: django/template/__init__.py
===================================================================
--- django/template/__init__.py	(revision 12820)
+++ django/template/__init__.py	(working copy)
@@ -570,7 +570,10 @@
                 if not lookup:
                     arg_vals.append(mark_safe(arg))
                 else:
-                    arg_vals.append(arg.resolve(context))
+                    try:
+                        arg_vals.append(arg.resolve(context))
+                    except VariableDoesNotExist:
+                        arg_vals.append(settings.TEMPLATE_STRING_IF_INVALID)
             if getattr(func, 'needs_autoescape', False):
                 new_obj = func(obj, autoescape=context.autoescape, *arg_vals)
             else:
@@ -745,11 +748,11 @@
                             TypeError,  # unsubscriptable object
                             ):
                         raise VariableDoesNotExist("Failed lookup for key [%s] in %r", (bit, current)) # missing attribute
-                except Exception, e:
-                    if getattr(e, 'silent_variable_failure', False):
-                        current = settings.TEMPLATE_STRING_IF_INVALID
-                    else:
-                        raise
+            except Exception, e:
+                if getattr(e, 'silent_variable_failure', False):
+                    current = settings.TEMPLATE_STRING_IF_INVALID
+                else:
+                    raise
 
         return current
 
Index: tests/regressiontests/templates/tests.py
===================================================================
--- tests/regressiontests/templates/tests.py	(revision 12820)
+++ tests/regressiontests/templates/tests.py	(working copy)
@@ -97,6 +97,10 @@
     def method(self):
         return "OtherClass.method"
 
+class SilentGetItemClass(object):
+    def __getitem__(self, key):
+        raise SomeException
+
 class UTF8Class:
     "Class whose __str__ returns non-ASCII data"
     def __str__(self):
@@ -552,6 +556,11 @@
             #filters should accept empty string constants
             'filter-syntax20': ('{{ ""|default_if_none:"was none" }}', {}, ""),
 
+            # regression tests for ticket #12554
+            'filter-syntax21': ("{{ a.b }}", {'a': SilentGetItemClass()}, ('', 'INVALID')),
+            'filter-syntax22': ("{{ a|default:notreal }}", {'a': 'test'}, ('test', 'test')),
+            'filter-syntax23': ("{{ a|default:notreal }}", {'a': ''}, ('', 'INVALID')),
+
             ### COMMENT SYNTAX ########################################################
             'comment-syntax01': ("{# this is hidden #}hello", {}, "hello"),
             'comment-syntax02': ("{# this is hidden #}hello{# foo #}", {}, "hello"),
