Skip to content

Commit

Permalink
Merge pull request #140 from mwootten/plus-signs
Browse files Browse the repository at this point in the history
Fix #132 by adjusting querystring processing
  • Loading branch information
magnusmanske authored Jan 19, 2024
2 parents d353efe + 506150e commit 9120e88
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 19 deletions.
10 changes: 0 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ wikibase = { git = "https://gitlab.com/tobias47n9e/wikibase_rs" }
tokio = { version = "^1", features = ["macros","fs","sync"] }
tokio-util = "*"
hyper = { version = "^0.14", features = ["full"] }
qstring = "*"
futures = "*"

[profile.release]
Expand Down
7 changes: 2 additions & 5 deletions src/form_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ impl FormParameters {
Self { ..Default::default() }
}

pub fn new_from_pairs(parameter_pairs: Vec<(&str, &str)>) -> Self {
pub fn new_from_pairs(parameter_pairs: HashMap<String, String>) -> Self {
let mut ret = Self::new();
ret.params = parameter_pairs
.iter()
.map(|(k, v)| (k.to_string(), v.to_string().replace("+", " ")))
.collect();
ret.params = parameter_pairs;
ret.ns = Self::ns_from_params(&ret.params);
ret.legacy_parameters();
ret
Expand Down
7 changes: 4 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub mod wdfist;

use tokio::fs::File as TokioFile;
use tokio_util::codec::{BytesCodec, FramedRead};
use qstring::QString;
use url::form_urlencoded;
use crate::form_parameters::FormParameters;
use app_state::AppState;
use platform::{MyResponse, Platform, ContentType};
Expand All @@ -35,8 +35,9 @@ use hyper::service::{make_service_fn, service_fn};
static NOTFOUND: &[u8] = b"Not Found";

async fn process_form(parameters:&str, state: Arc<AppState>) -> MyResponse {
let parameter_pairs = QString::from(parameters) ;
let parameter_pairs = parameter_pairs.to_pairs() ;
let parameter_pairs = form_urlencoded::parse(parameters.as_bytes())
.map(|(k, v)| (k.into_owned(), v.into_owned()))
.collect();
let mut form_parameters = FormParameters::new_from_pairs ( parameter_pairs ) ;

// Restart command?
Expand Down

0 comments on commit 9120e88

Please sign in to comment.