This repository was archived by the owner on Sep 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -128,16 +128,19 @@ function set_progress( float $pc, string $label ) {
128128
129129// Iterate by reference, so that we can modify the $patches array to add new entries
130130foreach ( $ patches as &$ patch ) {
131- $ patchSafe = preg_replace ( '/(?!^I)[^0-9a-f]/ ' , '' , $ patch );
132- $ data = gerrit_query ( "changes/?q=change: $ patchSafe&o=LABELS&o=CURRENT_REVISION " , true );
131+ if ( !preg_match ( '/^(I[0-9a-f]+|[0-9]+)$/ ' , $ patch ) ) {
132+ $ patch = htmlentities ( $ patch );
133+ abandon ( "Invalid patch number <em> $ patch</em> " );
134+ }
135+ $ data = gerrit_query ( "changes/?q=change: $ patch&o=LABELS&o=CURRENT_REVISION " , true );
133136
134137 if ( count ( $ data ) === 0 ) {
135- $ patchSafe = htmlentities ( $ patchSafe );
136- abandon ( "Could not find patch <em> $ patchSafe </em> " );
138+ $ patch = htmlentities ( $ patch );
139+ abandon ( "Could not find patch <em> $ patch </em> " );
137140 }
138141 if ( count ( $ data ) !== 1 ) {
139- $ patchSafe = htmlentities ( $ patchSafe );
140- abandon ( "Ambiguous query <em> $ patchSafe </em> " );
142+ $ patch = htmlentities ( $ patch );
143+ abandon ( "Ambiguous query <em> $ patch </em> " );
141144 }
142145
143146 // get the info
You can’t perform that action at this time.
0 commit comments