@ -145,89 +145,6 @@ public class Http_server_wkr implements Gfo_invk {
return page_html ;
}
private static final byte [ ]
Bry__file_lhs = Bry_ . new_a7 ( "file:" )
, Bry__file_mid = Bry_ . new_a7 ( "/file/" )
, Bry__file_fsys = Bry_ . new_a7 ( "/fsys" )
;
public static byte [ ] Replace_fsys_hack ( byte [ ] html_bry ) {
// init
Bry_bfr bfr = Bry_bfr_ . New ( ) ;
int len = html_bry . length ;
int pos = 0 ;
// loop while finding "file:.*/file/"
while ( true ) {
// find "file:"
int lhs_bgn = Bry_find_ . Find_fwd ( html_bry , Bry__file_lhs , pos ) ;
// exit if nothing found
if ( lhs_bgn = = Bry_find_ . Not_found )
break ;
// set lhs_end (after "file:")
int lhs_end = lhs_bgn + Bry__file_lhs . length ;
// skip if page literally starts with "file:"
if ( lhs_bgn = = 0 ) {
bfr . Add_mid ( html_bry , pos , lhs_end ) ;
pos = lhs_end ;
continue ;
}
// get quote char before "file:"
int quote_bgn = lhs_bgn - 1 ;
byte quote = html_bry [ quote_bgn ] ;
// skip if no quote found
if ( quote ! = Byte_ascii . Apos & & quote ! = Byte_ascii . Quote ) {
bfr . Add_mid ( html_bry , pos , lhs_end ) ;
pos = lhs_end ;
continue ;
}
// find end quote
int quote_end = Bry_find_ . Find_fwd ( html_bry , quote , lhs_end ) ;
// exit if no end quote
if ( quote_end = = Bry_find_ . Not_found )
break ;
// skip if "'file: ... '" is too long. should be no more than 300
if ( quote_end - lhs_end > 300 ) {
bfr . Add_mid ( html_bry , pos , quote_end ) ;
pos = quote_end ;
continue ;
}
// find "/file/"
int mid_bgn = Bry_find_ . Find_fwd ( html_bry , Bry__file_mid , lhs_bgn , quote_end ) ;
// skip if no "/file/"
if ( mid_bgn = = Bry_find_ . Not_found ) {
bfr . Add_mid ( html_bry , pos , quote_end ) ;
pos = quote_end ;
continue ;
}
// add everything up to "file:"
bfr . Add_mid ( html_bry , pos , lhs_bgn ) ;
// add "/fsys/"
bfr . Add ( Bry__file_fsys ) ;
// add everything up to quote
bfr . Add_mid ( html_bry , mid_bgn , quote_end ) ;
// move pos forward
pos = quote_end ;
}
// add rest
bfr . Add_mid ( html_bry , pos , len ) ;
return bfr . To_bry_and_clear ( ) ;
}
public Object Invk ( GfsCtx ctx , int ikey , String k , GfoMsg m ) {
if ( ctx . Match ( k , Invk_run ) ) { this . Run ( ) ; }
else return Gfo_invk_ . Rv_unhandled ;