Buggy code:
public class AjaxService extends HttpServlet { private static final long serialVersionUID = 1755139421903673627L ; private static final String HEADER_PRAGMA = "Pragma" ; private static final String HEADER_EXPIRES = "Expires" ; private static final String HEADER_CACHE_CONTROL = "Cache-Control" ; ORMManagerProvider ormManagerProvider ; public void setOrmManagerProvider ( ORMManagerProvider ormManagerProvider ) { } BeanProvider beanProvider ; public void setBeanProvider ( BeanProvider beanProvider ) { } AuthorityProvider authorityProvider ; public void setAuthorityProvider ( AuthorityProvider authorityProvider ) { } protected Presentation getPresentation ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { } Object [ ] getParams ( JsonRePresentation rep , Method method , HttpServletRequest request ) throws Exception { } protected final void preventCaching ( HttpServletResponse response ) { } @ Override protected void doGet ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { } void doRequests ( HttpServletRequest request , HttpServletResponse response , Reader input ) throws IOException , ServletException { } private String getStringFromJsonArray ( String errMessage , JsonRePresentation rep ) throws IOException , ParseException { } protected Object createFakeEntity ( Class < ? > clazz , Object primaryKey ) { } protected boolean doAction ( String beanName , String methodName , JsonRePresentation rep , HttpServletRequest request , AjaxRequestResult result ) throws Throwable { Object bean = ( ( beanProvider ) == null ) ? Class . forName ( beanName ) . newInstance ( ) : beanProvider . getBeanInstance ( beanName ) ; Method method = null ; for ( Method m : bean . getClass ( ) . getMethods ( ) ) if ( m . getName ( ) . equals ( methodName ) ) { method = m ; break ; } if ( method == null ) throw new RuntimeException ( ( "Unknown<seq2seq4repair_space>method<seq2seq4repair_space>" + methodName ) ) ; Arguments arguments = method . getAnnotation ( Arguments . class ) ; if ( null == arguments ) throw new RuntimeException ( "Method<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>visible<seq2seq4repair_space>for<seq2seq4repair_space>ajax<seq2seq4repair_space>call" ) ; if ( false && ( arguments . checkReferer ( ) ) ) { String ref = request . getHeader ( "Referer" ) ; if ( ref == null ) throw new RuntimeException ( "Invalid<seq2seq4repair_space>referer" ) ; <START_BUG> ref = ref . replaceFirst ( "http:////" , "" ) . replaceFirst ( "//.*$" , "" ) ; <END_BUG> String host = request . getHeader ( "Host" ) ; if ( host == null ) throw new RuntimeException ( "Invalid<seq2seq4repair_space>host" ) ; if ( ! ( ref . equalsIgnoreCase ( host ) ) ) { throw new RuntimeException ( ( ( ( ( "Bad<seq2seq4repair_space>referer<seq2seq4repair_space>" + ref ) + "<seq2seq4repair_space>not<seq2seq4repair_space>equals<seq2seq4repair_space>" ) + host ) + "<seq2seq4repair_space>host" ) ) ; } } Object [ ] params = getParams ( rep , method , request ) ; if ( ( authorityProvider ) != null ) { authorityProvider . checkMethodRequest ( request , method , params ) ; } try { result . setData ( method . invoke ( bean , params ) ) ; } catch ( Throwable th ) { throw ( th . getCause ( ) ) != null ? th . getCause ( ) : th ; } return true ; } @ Override protected void doPost ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { } public static void sendFile ( HttpServletResponse response , String fileName ) throws IOException { } }

Fix:
ref = ref . replaceFirst ( "http:////" , "" ) . replaceFirst ( "[\\://].*$" , "" ) ;