From 1277e58e686d5d5f32aba6c95de5885a5dc6b468 Mon Sep 17 00:00:00 2001 From: softsimon Date: Sat, 4 Sep 2021 23:21:15 +0400 Subject: [PATCH 1/2] Updated address regex to handle all types of addresses. fixes #301 fixes #750 --- backend/src/api/websocket-handler.ts | 2 +- .../src/app/components/search-form/search-form.component.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/api/websocket-handler.ts b/backend/src/api/websocket-handler.ts index 0f7445aef..7699a5a0d 100644 --- a/backend/src/api/websocket-handler.ts +++ b/backend/src/api/websocket-handler.ts @@ -80,7 +80,7 @@ class WebsocketHandler { } if (parsedMessage && parsedMessage['track-address']) { - if (/^([a-km-zA-HJ-NP-Z1-9]{26,35}|[a-km-zA-HJ-NP-Z1-9]{80}|[a-z]{2,5}1[ac-hj-np-z02-9]{8,87})$/ + if (/^([a-km-zA-HJ-NP-Z1-9]{26,35}|[a-km-zA-HJ-NP-Z1-9]{80}|[a-z]{2,5}1[ac-hj-np-z02-9]{8,100}|[A-Z]{2,5}1[AC-HJ-NP-Z02-9]{8,100})$/ .test(parsedMessage['track-address'])) { client['track-address'] = parsedMessage['track-address']; } else { diff --git a/frontend/src/app/components/search-form/search-form.component.ts b/frontend/src/app/components/search-form/search-form.component.ts index dcd3fab8c..098b42d1e 100644 --- a/frontend/src/app/components/search-form/search-form.component.ts +++ b/frontend/src/app/components/search-form/search-form.component.ts @@ -23,7 +23,7 @@ export class SearchFormComponent implements OnInit { searchForm: FormGroup; @Output() searchTriggered = new EventEmitter(); - regexAddress = /^([a-km-zA-HJ-NP-Z1-9]{26,35}|[a-km-zA-HJ-NP-Z1-9]{80}|[bB]?[a-z]{2,5}1[ac-hj-np-z02-9]{8,87})$/; + regexAddress = /^([a-km-zA-HJ-NP-Z1-9]{26,35}|[a-km-zA-HJ-NP-Z1-9]{80}|[a-z]{2,5}1[ac-hj-np-z02-9]{8,100}|[A-Z]{2,5}1[AC-HJ-NP-Z02-9]{8,100})$/; regexBlockhash = /^[0]{8}[a-fA-F0-9]{56}$/; regexTransaction = /^[a-fA-F0-9]{64}$/; regexBlockheight = /^[0-9]+$/; From b71330c60626def65f2eb7dd7d2d4fe5ad5963a7 Mon Sep 17 00:00:00 2001 From: softsimon Date: Sun, 5 Sep 2021 00:30:24 +0400 Subject: [PATCH 2/2] Lowercase Segwit uppercase addresses for tracking matching. --- backend/src/api/websocket-handler.ts | 6 +++++- frontend/src/app/components/address/address.component.ts | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/src/api/websocket-handler.ts b/backend/src/api/websocket-handler.ts index 7699a5a0d..29b3b7d8f 100644 --- a/backend/src/api/websocket-handler.ts +++ b/backend/src/api/websocket-handler.ts @@ -82,7 +82,11 @@ class WebsocketHandler { if (parsedMessage && parsedMessage['track-address']) { if (/^([a-km-zA-HJ-NP-Z1-9]{26,35}|[a-km-zA-HJ-NP-Z1-9]{80}|[a-z]{2,5}1[ac-hj-np-z02-9]{8,100}|[A-Z]{2,5}1[AC-HJ-NP-Z02-9]{8,100})$/ .test(parsedMessage['track-address'])) { - client['track-address'] = parsedMessage['track-address']; + let matchedAddress = parsedMessage['track-address']; + if (/^[A-Z]{2,5}1[AC-HJ-NP-Z02-9]{8,100}$/.test(parsedMessage['track-address'])) { + matchedAddress = matchedAddress.toLowerCase(); + } + client['track-address'] = matchedAddress; } else { client['track-address'] = null; } diff --git a/frontend/src/app/components/address/address.component.ts b/frontend/src/app/components/address/address.component.ts index ca0198c8f..a12de7343 100644 --- a/frontend/src/app/components/address/address.component.ts +++ b/frontend/src/app/components/address/address.component.ts @@ -69,6 +69,9 @@ export class AddressComponent implements OnInit, OnDestroy { this.transactions = null; document.body.scrollTo(0, 0); this.addressString = params.get('id') || ''; + if (/^[A-Z]{2,5}1[AC-HJ-NP-Z02-9]{8,100}$/.test(this.addressString)) { + this.addressString = this.addressString.toLowerCase(); + } this.seoService.setTitle($localize`:@@address.component.browser-title:Address: ${this.addressString}:INTERPOLATION:`); return merge(