<commit_before>package org.apache.cordova.oauthredirect;

import java.util.Map.Entry;
import java.util.Properties;
import java.io.IOException;

import android.util.Log;

import fi.iki.elonen.NanoHTTPD;

public class WebServer extends NanoHTTPD {
  private String code;
  private int port;

  public WebServer(int port) throws IOException {
    super(port);
    this.port = port;
    this.code = null;
  }

  public String getCode() {
    return this.code;
  }

  public void setCode(String c) {
    this.code = c;
  }

  @Override
  public Response serve(IHTTPSession session) {
    /**
    handler.post(new Runnable() {
      @Override
      public void run() {
        hello.setText(buf);
      }
    });
    **/

    //session.getQueryParameterString();
    //for (Entry<String, String> kv: session.getParms().entrySet()) {
    /**
    for (Entry<String, String> kv: session.getHeaders().entrySet()) {
      if (kv.getKey().equals("code")) { // Digital Ocean
        this.code = kv.getValue();
      }
    }
    **/
    this.code = "http://localhost:" + this.port +
      session.getUri() + 
      "?" + session.getQueryParameterString();

    String redirectUrl = "app://org.uproxy.colony" + session.getUri() + "?" + session.getQueryParameterString();

    String html = "<html><head>" +
      "<meta http-equiv='refresh' content='0;url=" + redirectUrl + "'>" + 
      "</head><body>" + 
      this.getCode() + 
      "<br>" + 
      "<a href='" + redirectUrl + "'>Go Back</a>" +
      "</body><script>" +
      "window.open('" + redirectUrl + "')" + // Or try to open automatically
      "</script></html>";
    return this.newFixedLengthResponse(html);
  }
}
<commit_msg>Filtering to properly set code<commit_after>package org.apache.cordova.oauthredirect;

import java.util.Map.Entry;
import java.util.Properties;
import java.io.IOException;

import android.util.Log;

import fi.iki.elonen.NanoHTTPD;

public class WebServer extends NanoHTTPD {
  private String code;
  private int port;

  public WebServer(int port) throws IOException {
    super(port);
    this.port = port;
    this.code = null;
  }

  public String getCode() {
    return this.code;
  }

  public void setCode(String c) {
    this.code = c;
  }

  @Override
  public Response serve(IHTTPSession session) {
    /**
    handler.post(new Runnable() {
      @Override
      public void run() {
        hello.setText(buf);
      }
    });
    **/

    //session.getQueryParameterString();
    //for (Entry<String, String> kv: session.getParms().entrySet()) {
    /**
    for (Entry<String, String> kv: session.getHeaders().entrySet()) {
      if (kv.getKey().equals("code")) { // Digital Ocean
        this.code = kv.getValue();
      }
    }
    **/

    String redirectUrl;
    String html = ""; 
    if (session.getQueryParameterString().indexOf("code") > -1 &&
        session.getQueryParameterString().indexOf("state") > -1) {
      this.code = "http://localhost:" + this.port +
        session.getUri() + 
        "?" + session.getQueryParameterString();

      redirectUrl = "app://org.uproxy.colony" + session.getUri() + "?" + session.getQueryParameterString();
      html = "<html><head>" +
        "<meta http-equiv='refresh' content='0;url=" + redirectUrl + "'>" + 
        "</head><body>" + 
        this.getCode() + 
        "<br>" + 
        "<a href='" + redirectUrl + "'>Go Back</a>" +
        "</body><script>" +
        "window.open('" + redirectUrl + "')" + // Or try to open automatically
        "</script></html>";
    } 

    return this.newFixedLengthResponse(html);
  }
}

{'fraction_non_alphanumeric': 0.165499859983198, 'fraction_numerical': 0.0011201344161299357, 'mean_word_length': 2.6598360655737703, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2278612', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1115, 'n_words': 229}