Its not illegal, I have done this repair on a friends car for the MOT, as long as it is a good joint (no leaks) then its not a problem. The difficulty in reality is actually flaring the end of the existing fitted pipe while its on the car. It takes a fair bit of pressure with the flaring tool, It wouldnt normally be a problem as the tool would be clamped in a vice on a bench. this isnt so easy underneath the car, but it can be done. You also need to be confident that the bit of pipe you are leaving on the car is good enough for the MOT.