Fix len miscalculation in grimoire string replace (#794)
* Fix len miscalculation in grimoire string replace * ok Rust i was writing JS these days Co-authored-by: Andrea Fioraldi <andrea.fioraldi@trellix.com>
This commit is contained in:
parent
f6bd99fc4d
commit
c0bb1bc1e6
@ -294,7 +294,8 @@ where
|
|||||||
if bytes.len() < token_1.len() {
|
if bytes.len() < token_1.len() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for i in 0..(bytes.len() - token_1.len()) {
|
let mut i = 0;
|
||||||
|
while i < bytes.len() - token_1.len() {
|
||||||
if bytes[i..].starts_with(token_1) {
|
if bytes[i..].starts_with(token_1) {
|
||||||
bytes.splice(i..(i + token_1.len()), token_2.clone());
|
bytes.splice(i..(i + token_1.len()), token_2.clone());
|
||||||
|
|
||||||
@ -303,6 +304,7 @@ where
|
|||||||
break 'first;
|
break 'first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
i += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -312,7 +314,8 @@ where
|
|||||||
if bytes.len() < token_1.len() {
|
if bytes.len() < token_1.len() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for i in 0..(bytes.len() - token_1.len()) {
|
let mut i = 0;
|
||||||
|
while i < bytes.len() - token_1.len() {
|
||||||
if bytes[i..].starts_with(token_1) {
|
if bytes[i..].starts_with(token_1) {
|
||||||
bytes.splice(i..(i + token_1.len()), token_2.clone());
|
bytes.splice(i..(i + token_1.len()), token_2.clone());
|
||||||
|
|
||||||
@ -321,6 +324,7 @@ where
|
|||||||
break 'second;
|
break 'second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
i += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user