Fix for JENKINS-7032 and JENKINS-13366

Hello, 
does somebody of the other trac-plugin developers want to do a review of my changes?
I will merge my changes in about seven days into the master branch when no feedback is given.
Bye, bye
Gerd