A judgment declaring a marriage void or dissolved by the action or claim of either party shall have the effect to terminate such marriage as to both parties, except that neither party shall be capable of contracting marriage with a third person, until the action has been heard and determined on appeal, and if no appeal be taken, until the expiration of the period allowed by law to take such appeal; and if he or she does so contract, such party shall be liable thereof as if such judgment had not been given; Provided, however, That the parties to an uncontested action to void or dissolve a marriage shall be capable of contracting marriage with a third person immediately after said judgment is declared.