Prevented potential key/value parsing bug in qurey_value(string, string), updated README

This commit is contained in:
Baldomo
2020-12-04 11:04:49 +01:00
parent 81c10e755c
commit 94861f36bb
3 changed files with 8 additions and 10 deletions

View File

@@ -27,9 +27,8 @@ The table below is a simple documentation of the URL query keys and values used
| `flags` | `--vo%3Dgpu` | Custom command options and flags to be passed to the video player |
### Playlist and `enqueue` functionality
For `enqueue` to work properly with any mpv-based player, the playes has to be able to read commands from a `fifo` name pipe. This can be achieved by adding the following lines to any of the user's startup utilities/files, e.g. `.bashrc`, `.zshrc` or `.profile`.
For `enqueue` to work properly with any mpv-based player, the playes has to be able to read commands from a `fifo` name pipe. This can be achieved by adding the following line to the video player's configuration (usually `.conf/mpv/mpv.conf` for mpv).
```sh
mpvsocket=/tmp/mpvsocket
[[ ! -p /tmp/mpvsocket ]] && mkfifo /tmp/mpvsocket
```
input-ipc-server=/tmp/mpvsocket
```

View File

@@ -1,5 +1,5 @@
#ifndef MPVIPC_H_
#define MPVIPC_H_
#ifndef MPVIPC_HPP_
#define MPVIPC_HPP_
#include <cstring>
#include <unistd.h>

View File

@@ -1,5 +1,5 @@
#ifndef MPVOPTS_H_
#define MPVOPTS_H_
#ifndef MPVOPTS_HPP_
#define MPVOPTS_HPP_
#include <curl/curl.h>
#include <cstring>
@@ -146,7 +146,7 @@ string url_decode(const string encoded) {
*/
string query_value(string query, string key) {
// Find the beginning of the last occurrence of `key` in `query`
auto pos = query.rfind(key);
auto pos = query.rfind(key + "=");
if (pos == string::npos) return "";
// Offset calculation (beginning of the value string associated with `key`):
@@ -159,5 +159,4 @@ string query_value(string query, string key) {
return query.substr(offset, query.find('&', pos) - offset);
}
#endif