NFA string acceptance with loop of epsilon transitions
An algorithm for testing whether an NFA accepts a string has the following specification:


Input: NFA $A$ and word $w$
Output: Yes if $A$ accepts $w$, No if $A$ doesn't accept $w$


In particular, the algorithm must always terminate. What algorithm you use is up to you.



One way to overcome the problem of $\epsilon$-loops is to compute, for each prefix of $w$, the set of states that the NFA can reach. To this end, for every state $q$ we define $N_\epsilon(q)$ as the set of states reachable from $q$ via (possibly zero) $\epsilon$-transitions. You can compute $N_\epsilon(q)$ using a graph traversal algorithm such as BFS/DFS.

Given a word $w = \sigma_1\ldots \sigma_n$, we define the set of states $R_i$ reachable after reading the first $i$ letters as follows:


$R_0 = N_\epsilon(q_0)$.
For $i = 1,\ldots,n$, $R_i$ is the union of $N_\epsilon(q')$ for all $q' \in \delta(q,\sigma_i)$ and all $q \in R_{i-1}$.


The NFA accepts $w$ iff $R_n \cap F \neq \emptyset$, that is, if $R_n$ contains an accepting state.



In your example, $N_\epsilon(1) = N_\epsilon(2) = \{1,2\}$. The fact that the graph induced by the $\epsilon$-transitions contains directed cycles is not problematic at all for this approach, since we only care about which states are reachable from which.