From a scan of what looks like the official rules:
If a leaky pipe is connected to the last pipe card it can be any shape as long as it continues the pipeline.
Reviewing the rules from this site, the relevant line is:
"If the player adds a leaky pipe to the end of the player’s set of
pipes the card can be any shape as long as it allows the player to
have at least one path available to add pipes in future turns."
I could not find any rules that expressly forbids forcing a players pipeline towards a path that blocks the player's ability to win. So as long as the player can continue their pipeline path at least once more after a leaky pipe is placed, then it's a fair play (based on the rules).
Personally, for better games, I would bring up this situation with my opponents and decide if we want to allow this tactic and declare the blocked player lost, or disallow this tactic by assuming the rules mean:
...as long as it continues the pipeline with sufficient space for the player to meet the required number of pipes to win.
If you are the Rule Lawyer type, then the play you described is allowed. I just suggest you bring it up before play, so everyone can guard against it, instead of springing it on your opponents, causing this type of argument.
Good Question.