```python
def strip_ends(text: str, mark: str) -> str:
    """The text with all stated characters removed from both ends."""
    if not mark:
        return text
    out = text
    while out.startswith(mark):
        out = out[len(mark):]
    while out.endswith(mark):
        out = out[:-len(mark)]
    return out
```